]> pd.if.org Git - nbds/blobdiff - include/list.h
work in progress
[nbds] / include / list.h
index 7eeda46aff1e65ffa30accecd26713b9644f40cd..c6db953ca43abe1761fb2af839a0f44fe9c897cd 100644 (file)
@@ -1,19 +1,28 @@
 #ifndef LIST_H
 #define LIST_H
 
 #ifndef LIST_H
 #define LIST_H
 
-#include "datatype.h"
 #include "map.h"
 
 typedef struct ll list_t;
 #include "map.h"
 
 typedef struct ll list_t;
+typedef struct ll_iter ll_iter_t;
 
 
-extern map_type_t MAP_TYPE_LIST;
+list_t *   ll_alloc   (const datatype_t *key_type);
+map_val_t  ll_cas     (list_t *ll, map_key_t key, map_val_t expected_val, map_val_t new_val);
+map_val_t  ll_lookup  (list_t *ll, map_key_t key);
+map_val_t  ll_remove  (list_t *ll, map_key_t key);
+size_t     ll_count   (list_t *ll);
+void       ll_print   (list_t *ll, int verbose);
+void       ll_free    (list_t *ll);
+map_key_t  ll_min_key (list_t *sl);
 
 
-list_t * ll_alloc  (const datatype_t *key_type);
-uint64_t ll_cas    (list_t *ll, void *key, uint64_t expected_val, uint64_t new_val);
-uint64_t ll_lookup (list_t *ll, void *key);
-uint64_t ll_remove (list_t *ll, void *key);
-uint64_t ll_count  (list_t *ll);
-void     ll_print  (list_t *ll);
-void     ll_free   (list_t *ll);
+ll_iter_t * ll_iter_begin (list_t *ll, map_key_t key);
+map_val_t   ll_iter_next  (ll_iter_t *iter, map_key_t *key_ptr);
+void        ll_iter_free  (ll_iter_t *iter);
+
+static const map_impl_t MAP_IMPL_LL = { 
+    (map_alloc_t)ll_alloc, (map_cas_t)ll_cas, (map_get_t)ll_lookup, (map_remove_t)ll_remove, 
+    (map_count_t)ll_count, (map_print_t)ll_print, (map_free_t)ll_free, (map_iter_begin_t)ll_iter_begin,
+    (map_iter_next_t)ll_iter_next, (map_iter_free_t)ll_iter_free
+};
 
 #endif//LIST_H
 
 #endif//LIST_H