4 * Copyright (c) 2011-2012 Pacman Development Team <pacman-dev@archlinux.org>
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.
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.
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/>.
20 #ifndef _ALPM_PKGHASH_H
21 #define _ALPM_PKGHASH_H
26 #include "alpm_list.h"
30 * @brief A hash table for holding alpm_pkg_t objects.
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.
35 struct __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 */
40 /** number of buckets in hash table */
42 /** number of entries in hash table */
44 /** max number of entries before a resize is needed */
48 typedef struct __alpm_pkghash_t alpm_pkghash_t
;
50 alpm_pkghash_t
*_alpm_pkghash_create(unsigned int size
);
52 alpm_pkghash_t
*_alpm_pkghash_add(alpm_pkghash_t
*hash
, alpm_pkg_t
*pkg
);
53 alpm_pkghash_t
*_alpm_pkghash_add_sorted(alpm_pkghash_t
*hash
, alpm_pkg_t
*pkg
);
54 alpm_pkghash_t
*_alpm_pkghash_remove(alpm_pkghash_t
*hash
, alpm_pkg_t
*pkg
, alpm_pkg_t
**data
);
56 void _alpm_pkghash_free(alpm_pkghash_t
*hash
);
58 alpm_pkg_t
*_alpm_pkghash_find(alpm_pkghash_t
*hash
, const char *name
);
60 #endif /* _ALPM_PKGHASH_H */