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 unsigned int n_buckets
;
34 unsigned int n_elements
;
37 unsigned int n_used_buckets
;
38 unsigned int n_collisions
;
39 unsigned int max_bucket_len
;
40 unsigned int n_hits
, n_misses
;
43 void hash_table_init(const char *name
, hash_table_t
* hash
, int len
);
44 void hash_table_deinit(hash_table_t
* hash
);
45 void hash_print_stats(hash_table_t
* hash
);
46 void *hash_table_get(hash_table_t
* hash
, const char *key
);
47 int hash_table_insert(hash_table_t
* hash
, const char *key
, void *value
);
48 int hash_table_remove(hash_table_t
* has
, const char *key
);
49 void hash_table_foreach(hash_table_t
* hash
,
50 void (*f
) (const char *key
, void *entry
, void *data
),
53 #endif /* _HASH_TABLE_H_ */