work in progress
[nbds] / include / hashtable.h
1 #ifndef HASHTABLE_H
2 #define HASHTABLE_H
3
4 #include "map.h"
5
6 typedef struct ht hashtable_t;
7 typedef struct ht_iter ht_iter_t;
8
9 hashtable_t * ht_alloc      (const datatype_t *key_type);
10 map_val_t     ht_cas        (hashtable_t *ht, map_key_t key, map_val_t expected_val, map_val_t val);
11 map_val_t     ht_get        (hashtable_t *ht, map_key_t key);
12 map_val_t     ht_remove     (hashtable_t *ht, map_key_t key);
13 size_t        ht_count      (hashtable_t *ht);
14 void          ht_print      (hashtable_t *ht, int verbose);
15 void          ht_free       (hashtable_t *ht);
16 ht_iter_t *   ht_iter_begin (hashtable_t *ht, map_key_t key);
17 map_val_t     ht_iter_next  (ht_iter_t *iter, map_key_t *key_ptr);
18 void          ht_iter_free  (ht_iter_t *iter);
19
20 static const map_impl_t MAP_IMPL_HT = { 
21     (map_alloc_t)ht_alloc, (map_cas_t)ht_cas, (map_get_t)ht_get, (map_remove_t)ht_remove, 
22     (map_count_t)ht_count, (map_print_t)ht_print, (map_free_t)ht_free,
23     (map_iter_begin_t)ht_iter_begin, (map_iter_next_t)ht_iter_next, (map_iter_free_t)ht_iter_free
24 };
25
26 #endif//HASHTABLE_H