1 /* hash.h - hash tables for opkg
3 Steven M. Ayer, Jamey Hicks
5 Copyright (C) 2002 Compaq Computer Corporation
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License as
9 published by the Free Software Foundation; either version 2, or (at
10 your option) any later version.
12 This program is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 General Public License for more details.
18 #ifndef _HASH_TABLE_H_
19 #define _HASH_TABLE_H_
21 typedef struct hash_entry hash_entry_t;
22 typedef struct hash_table hash_table_t;
27 struct hash_entry * next;
32 hash_entry_t * entries;
33 int n_entries; /* number of buckets */
35 const char * (*hash_entry_key)(void * data);
38 int hash_table_init(const char *name, hash_table_t *hash, int len);
39 void hash_table_deinit(hash_table_t *hash);
40 void *hash_table_get(hash_table_t *hash, const char *key);
41 int hash_table_insert(hash_table_t *hash, const char *key, void *value);
42 int hash_table_remove(hash_table_t *has, const char *key);
43 void hash_table_foreach(hash_table_t *hash, void (*f)(const char *key, void *entry, void *data), void *data);
45 #endif /* _HASH_TABLE_H_ */