libalpm
Arch Linux Package Manager Library
pkghash.h
Go to the documentation of this file.
1/*
2 * pkghash.h
3 *
4 * Copyright (c) 2011-2024 Pacman Development Team <pacman-dev@lists.archlinux.org>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef ALPM_PKGHASH_H
21#define ALPM_PKGHASH_H
22
23#include <stdlib.h>
24
25#include "alpm.h"
26#include "alpm_list.h"
27
28
29/**
30 * @brief A hash table for holding alpm_pkg_t objects.
31 *
32 * A combination of a hash table and a list, allowing for fast look-up
33 * by package name but also iteration over the packages.
34 */
35struct _alpm_pkghash_t {
36 /** data held by the hash table */
37 alpm_list_t **hash_table;
38 /** head node of the hash table data in normal list format */
39 alpm_list_t *list;
40 /** number of buckets in hash table */
41 unsigned int buckets;
42 /** number of entries in hash table */
43 unsigned int entries;
44 /** max number of entries before a resize is needed */
45 unsigned int limit;
46};
47
48typedef struct _alpm_pkghash_t alpm_pkghash_t;
49
50alpm_pkghash_t *_alpm_pkghash_create(unsigned int size);
51
52alpm_pkghash_t *_alpm_pkghash_add(alpm_pkghash_t **hash, alpm_pkg_t *pkg);
53alpm_pkghash_t *_alpm_pkghash_add_sorted(alpm_pkghash_t **hash, alpm_pkg_t *pkg);
54alpm_pkghash_t *_alpm_pkghash_remove(alpm_pkghash_t *hash, alpm_pkg_t *pkg, alpm_pkg_t **data);
55
56void _alpm_pkghash_free(alpm_pkghash_t *hash);
57
58alpm_pkg_t *_alpm_pkghash_find(alpm_pkghash_t *hash, const char *name);
59
60#endif /* ALPM_PKGHASH_H */
A doubly linked list.
Definition alpm_list.h:51