add iterators to hashtable, skiplist, and list
[nbds] / include / skiplist.h
1 #ifndef SKIPLIST_H
2 #define SKIPLIST_H
3
4 #include "map.h"
5
6 typedef struct sl skiplist_t;
7 typedef struct sl_iter sl_iter_t;
8
9 skiplist_t *sl_alloc (const datatype_t *key_type);
10 uint64_t sl_cas     (skiplist_t *sl, void *key, uint64_t expected_val, uint64_t new_val);
11 uint64_t sl_lookup  (skiplist_t *sl, void *key);
12 uint64_t sl_remove  (skiplist_t *sl, void *key);
13 uint64_t sl_count   (skiplist_t *sl);
14 void     sl_print   (skiplist_t *sl);
15 void     sl_free    (skiplist_t *sl);
16 void *   sl_min_key (skiplist_t *sl);
17
18 sl_iter_t *sl_iter_start (skiplist_t *sl, void *key);
19 sl_iter_t *sl_iter_next  (sl_iter_t *iter);
20 uint64_t   sl_iter_val   (sl_iter_t *iter);
21 void *     sl_iter_key   (sl_iter_t *iter);
22
23 static const map_impl_t sl_map_impl = { 
24     (map_alloc_t)sl_alloc, (map_cas_t)sl_cas, (map_get_t)sl_lookup, (map_remove_t)sl_remove, 
25     (map_count_t)sl_count, (map_print_t)sl_print, (map_free_t)sl_free
26 };
27
28 #endif//SKIPLIST_H