1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
/* hashtab.h
*
* generic hash table routines */
struct hashtab_order {
int which;
struct hashtab_elem *elem;
struct hashtab *ht;
};
struct hashtab_elem {
void *key;
unsigned int key_len;
unsigned int hashval;
void *data;
struct hashtab_elem *prev, *next;
struct hashtab *ht; /* so we don't have to pass the table
for all of those data manipulation
calls... */
};
struct hashtab {
unsigned long table_size; /* number of buckets */
unsigned long items_hashed; /* number of items in the table */
unsigned long resize_size; /* num items hashed after which we
should increase the number of
buckets */
struct hashtab_elem **table;
int numeric; /* If nonzero, this is a numeric hash
table, so the length of items
passed shouldn't be truncated.
This is also doubles as the size of
the data to be added. */
};
struct hashtab *hashtab_init PARAMS((int numeric));
struct hashtab_elem *hashtab_create PARAMS((struct hashtab *ht, void *key,
unsigned int len));
struct hashtab_elem *hashtab_find PARAMS((struct hashtab *ht, void *key,
unsigned int len));
void *hashtab_get_key PARAMS((struct hashtab_elem *he));
void *hashtab_get_value PARAMS((struct hashtab_elem *he));
void hashtab_set_value PARAMS((struct hashtab_elem *he,
void *v, unsigned int len));
struct hashtab_elem *hashtab_first PARAMS((struct hashtab *ht,
struct hashtab_order *ho));
struct hashtab_elem *hashtab_next PARAMS((struct hashtab_order *ho));
void hashtab_dump_keys PARAMS((struct hashtab *ht, FILE *out));
void hashtab_delete PARAMS((struct hashtab_elem *he));
|