2011-01-06 09:32:17 -05:00
|
|
|
/*
|
|
|
|
* pkghash.h
|
|
|
|
*
|
2014-01-01 05:24:48 -05:00
|
|
|
* Copyright (c) 2011-2014 Pacman Development Team <pacman-dev@archlinux.org>
|
2011-01-06 09:32:17 -05:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _ALPM_PKGHASH_H
|
|
|
|
#define _ALPM_PKGHASH_H
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include "alpm.h"
|
|
|
|
#include "alpm_list.h"
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2011-06-28 09:26:39 -04:00
|
|
|
* @brief A hash table for holding alpm_pkg_t objects.
|
2011-01-06 09:32:17 -05:00
|
|
|
*
|
|
|
|
* A combination of a hash table and a list, allowing for fast look-up
|
|
|
|
* by package name but also iteration over the packages.
|
|
|
|
*/
|
2011-06-28 00:56:29 -04:00
|
|
|
struct __alpm_pkghash_t {
|
2011-01-06 09:32:17 -05:00
|
|
|
/** data held by the hash table */
|
|
|
|
alpm_list_t **hash_table;
|
|
|
|
/** head node of the hash table data in normal list format */
|
|
|
|
alpm_list_t *list;
|
2012-01-02 14:29:40 -05:00
|
|
|
/** number of buckets in hash table */
|
|
|
|
unsigned int buckets;
|
|
|
|
/** number of entries in hash table */
|
|
|
|
unsigned int entries;
|
|
|
|
/** max number of entries before a resize is needed */
|
|
|
|
unsigned int limit;
|
2011-01-06 09:32:17 -05:00
|
|
|
};
|
|
|
|
|
2011-06-28 00:56:29 -04:00
|
|
|
typedef struct __alpm_pkghash_t alpm_pkghash_t;
|
2011-02-25 09:11:37 -05:00
|
|
|
|
2012-01-02 14:29:40 -05:00
|
|
|
alpm_pkghash_t *_alpm_pkghash_create(unsigned int size);
|
2011-01-06 09:32:17 -05:00
|
|
|
|
2011-06-28 00:56:29 -04:00
|
|
|
alpm_pkghash_t *_alpm_pkghash_add(alpm_pkghash_t *hash, alpm_pkg_t *pkg);
|
|
|
|
alpm_pkghash_t *_alpm_pkghash_add_sorted(alpm_pkghash_t *hash, alpm_pkg_t *pkg);
|
|
|
|
alpm_pkghash_t *_alpm_pkghash_remove(alpm_pkghash_t *hash, alpm_pkg_t *pkg, alpm_pkg_t **data);
|
2011-01-06 09:32:17 -05:00
|
|
|
|
2011-06-28 00:56:29 -04:00
|
|
|
void _alpm_pkghash_free(alpm_pkghash_t *hash);
|
2011-01-06 09:32:17 -05:00
|
|
|
|
2011-06-28 00:56:29 -04:00
|
|
|
alpm_pkg_t *_alpm_pkghash_find(alpm_pkghash_t *hash, const char *name);
|
2011-01-06 09:32:17 -05:00
|
|
|
|
|
|
|
#endif /* _ALPM_PKGHASH_H */
|