u_int -> unsigned int
[eleutheria.git] / genstructs / htable / htable.h
blob2a922b2a9452ae6dcde178d13a10b51e79121444
1 #ifndef HTABLE_H
2 #define HTABLE_H
4 #include <sys/queue.h>
6 typedef struct hnode {
7 const void *hn_key;
8 void *hn_data;
9 TAILQ_ENTRY(hnode) hn_next;
10 } hnode_t;
12 typedef struct htable {
13 size_t ht_size; /* size must be a power of 2 */
14 unsigned int ht_used;
15 unsigned int (*ht_hashf)(const void *key);
16 int (*ht_cmpf)(const void *arg1, const void *arg2);
17 void (*ht_printf)(const void *key, const void *data);
18 TAILQ_HEAD(htablehead, hnode) *ht_table;
19 } htable_t;
21 typedef struct htablehead hhead_t;
23 typedef enum {
24 HT_OK,
25 HT_NOMEM,
26 HT_NOTFOUND
27 } htret_t;
29 /* Function prototypes */
30 htret_t htable_init(htable_t *htable, size_t size);
31 void htable_free(htable_t *htable);
32 htret_t htable_insert(htable_t *htable, const void *key, void *data);
33 htret_t htable_remove(htable_t *htable, const void *key);
34 void *htable_search(const htable_t *htable, const void *key);
35 void htable_print(const htable_t *htable);
37 #endif /* HTABLE_H */