Read pkgcache into hash
[pacman-ng.git] / lib / libalpm / pkghash.h
blob7f90cb176b1d99d00444885237a0c5f02e26bcbc
1 /*
2 * pkghash.h
4 * Copyright (c) 2011 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
23 #include <stdlib.h>
25 #include "alpm.h"
26 #include "alpm_list.h"
29 /**
30 * @brief A hash table for holding pmpkg_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 __pmpkghash_t {
36 /** data held by the hash table */
37 alpm_list_t **hash_table;
38 /** number of buckets in hash table */
39 size_t buckets;
40 /** number of entries in hash table */
41 size_t entries;
42 /** head node of the hash table data in normal list format */
43 alpm_list_t *list;
46 pmpkghash_t *_alpm_pkghash_create(size_t size);
48 pmpkghash_t *_alpm_pkghash_add(pmpkghash_t *hash, pmpkg_t *pkg);
49 pmpkghash_t *_alpm_pkghash_add_sorted(pmpkghash_t *hash, pmpkg_t *pkg);
50 pmpkghash_t *_alpm_pkghash_remove(pmpkghash_t *hash, pmpkg_t *pkg, pmpkg_t *data);
52 void _alpm_pkghash_free(pmpkghash_t *hash);
54 pmpkg_t *_alpm_pkghash_find(pmpkghash_t *hash, const char *name);
56 #define MAX_HASH_LOAD 0.7
58 #endif /* _ALPM_PKGHASH_H */