generic map iterator interface
[nbds] / include / list.h
1 #ifndef LIST_H
2 #define LIST_H
3
4 #include "map.h"
5
6 typedef struct ll list_t;
7 typedef struct ll_iter ll_iter_t;
8
9 list_t * ll_alloc   (const datatype_t *key_type);
10 uint64_t ll_cas     (list_t *ll, void *key, uint64_t expected_val, uint64_t new_val);
11 uint64_t ll_lookup  (list_t *ll, void *key);
12 uint64_t ll_remove  (list_t *ll, void *key);
13 uint64_t ll_count   (list_t *ll);
14 void     ll_print   (list_t *ll);
15 void     ll_free    (list_t *ll);
16 void *   ll_min_key (list_t *sl);
17
18 ll_iter_t * ll_iter_begin (list_t *ll, void *key);
19 uint64_t    ll_iter_next  (ll_iter_t *iter, void **key_ptr);
20 void        ll_iter_free  (ll_iter_t *iter);
21
22 static const map_impl_t ll_map_impl = { 
23     (map_alloc_t)ll_alloc, (map_cas_t)ll_cas, (map_get_t)ll_lookup, (map_remove_t)ll_remove, 
24     (map_count_t)ll_count, (map_print_t)ll_print, (map_free_t)ll_free, (map_iter_begin_t)ll_iter_begin,
25     (map_iter_next_t)ll_iter_next, (map_iter_free_t)ll_iter_free
26 };
27
28 #endif//LIST_H