]> pd.if.org Git - nbds/blobdiff - include/hashtable.h
add iterators to hashtable, skiplist, and list
[nbds] / include / hashtable.h
index 9a32abc94746fc2bb966013572f7b209c688af4f..5ae84c11db2d670df7c44523cbf02bf2b391ee97 100644 (file)
@@ -4,6 +4,7 @@
 #include "map.h"
 
 typedef struct ht hashtable_t;
+typedef struct ht_iter ht_iter_t;
 
 hashtable_t *ht_alloc (const datatype_t *key_type);
 uint64_t ht_cas    (hashtable_t *ht, void *key, uint64_t expected_val, uint64_t val);
@@ -13,6 +14,12 @@ uint64_t ht_count  (hashtable_t *ht);
 void     ht_print  (hashtable_t *ht);
 void     ht_free   (hashtable_t *ht);
 
+ht_iter_t *ht_iter_start (hashtable_t *ht, void *key);
+ht_iter_t *ht_iter_next  (ht_iter_t *iter);
+uint64_t   ht_iter_val   (ht_iter_t *iter);
+uint64_t   ht_iter_key   (ht_iter_t *iter);
+void       ht_iter_free  (ht_iter_t *iter);
+
 static const map_impl_t ht_map_impl = { 
     (map_alloc_t)ht_alloc, (map_cas_t)ht_cas, (map_get_t)ht_get, (map_remove_t)ht_remove, 
     (map_count_t)ht_count, (map_print_t)ht_print, (map_free_t)ht_free