add iterators to hashtable, skiplist, and list
[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 uint64_t ht_cas    (hashtable_t *ht, void *key, uint64_t expected_val, uint64_t val);
11 uint64_t ht_get    (hashtable_t *ht, void *key);
12 uint64_t ht_remove (hashtable_t *ht, void *key);
13 uint64_t ht_count  (hashtable_t *ht);
14 void     ht_print  (hashtable_t *ht);
15 void     ht_free   (hashtable_t *ht);
16
17 ht_iter_t *ht_iter_start (hashtable_t *ht, void *key);
18 ht_iter_t *ht_iter_next  (ht_iter_t *iter);
19 uint64_t   ht_iter_val   (ht_iter_t *iter);
20 uint64_t   ht_iter_key   (ht_iter_t *iter);
21 void       ht_iter_free  (ht_iter_t *iter);
22
23 static const map_impl_t ht_map_impl = { 
24     (map_alloc_t)ht_alloc, (map_cas_t)ht_cas, (map_get_t)ht_get, (map_remove_t)ht_remove, 
25     (map_count_t)ht_count, (map_print_t)ht_print, (map_free_t)ht_free
26 };
27
28 #endif//HASHTABLE_H