2 #define HEADER_HASH_H 1
9 typedef list_elem hash_elem;
11 #define hash_entry(HASH_ELEM, STRUCT, MEMBER) \
12 ((STRUCT *) ((uint8_t *) (HASH_ELEM) - offsetof (STRUCT, MEMBER)))
14 typedef bool hash_less_func (const hash_elem *a, const hash_elem *b,
16 typedef unsigned hash_hash_func (const hash_elem *, void *aux);
35 bool hash_init (struct hash *, hash_less_func *, hash_hash_func *, void *aux);
36 void hash_clear (struct hash *);
37 void hash_destroy (struct hash *);
39 hash_elem *hash_insert (struct hash *, hash_elem *);
40 hash_elem *hash_replace (struct hash *, hash_elem *);
41 hash_elem *hash_find (struct hash *, hash_elem *);
42 hash_elem *hash_delete (struct hash *, hash_elem *);
44 void hash_first (struct hash_iterator *, struct hash *);
45 hash_elem *hash_next (struct hash_iterator *);
46 hash_elem *hash_cur (struct hash_iterator *);
48 size_t hash_size (struct hash *);
49 bool hash_empty (struct hash *);
51 unsigned hash_bytes (const void *, size_t);
52 unsigned hash_string (const char *);
53 unsigned hash_int (int);