libalpm
Arch Linux Package Manager Library
|
00001 /* 00002 * pkghash.h 00003 * 00004 * Copyright (c) 2011 Pacman Development Team <pacman-dev@archlinux.org> 00005 * 00006 * This program is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU General Public License as published by 00008 * the Free Software Foundation; either version 2 of the License, or 00009 * (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00018 */ 00019 00020 #ifndef _ALPM_PKGHASH_H 00021 #define _ALPM_PKGHASH_H 00022 00023 #include <stdlib.h> 00024 00025 #include "alpm.h" 00026 #include "alpm_list.h" 00027 00028 00029 /** 00030 * @brief A hash table for holding alpm_pkg_t objects. 00031 * 00032 * A combination of a hash table and a list, allowing for fast look-up 00033 * by package name but also iteration over the packages. 00034 */ 00035 struct __alpm_pkghash_t { 00036 /** data held by the hash table */ 00037 alpm_list_t **hash_table; 00038 /** head node of the hash table data in normal list format */ 00039 alpm_list_t *list; 00040 /** number of buckets in hash table */ 00041 unsigned int buckets; 00042 /** number of entries in hash table */ 00043 unsigned int entries; 00044 /** max number of entries before a resize is needed */ 00045 unsigned int limit; 00046 }; 00047 00048 typedef struct __alpm_pkghash_t alpm_pkghash_t; 00049 00050 alpm_pkghash_t *_alpm_pkghash_create(unsigned int size); 00051 00052 alpm_pkghash_t *_alpm_pkghash_add(alpm_pkghash_t *hash, alpm_pkg_t *pkg); 00053 alpm_pkghash_t *_alpm_pkghash_add_sorted(alpm_pkghash_t *hash, alpm_pkg_t *pkg); 00054 alpm_pkghash_t *_alpm_pkghash_remove(alpm_pkghash_t *hash, alpm_pkg_t *pkg, alpm_pkg_t **data); 00055 00056 void _alpm_pkghash_free(alpm_pkghash_t *hash); 00057 00058 alpm_pkg_t *_alpm_pkghash_find(alpm_pkghash_t *hash, const char *name); 00059 00060 #endif /* _ALPM_PKGHASH_H */