]> pd.if.org Git - nbds/blob - include/map.h
all structures now support arbitrary type keys with a fast path for integers
[nbds] / include / map.h
1 #ifndef MAP_H
2 #define MAP_H
3
4 typedef struct map map_t;
5
6 typedef const struct map_impl *map_type_t;
7
8 typedef int      (*cmp_fun_t)   (void *, void *);
9 typedef void *   (*clone_fun_t) (void *);
10 typedef uint32_t (*hash_fun_t)  (void *);
11
12 extern map_type_t MAP_TYPE_HASHTABLE;
13 extern map_type_t MAP_TYPE_SKIPLIST;
14 extern map_type_t MAP_TYPE_LIST;
15
16 map_t *  map_alloc  (map_type_t map_type, cmp_fun_t cmp_fun, hash_fun_t hash_fun, clone_fun_t clone_fun);
17 uint64_t map_get    (map_t *map, void *key);
18 uint64_t map_set    (map_t *map, void *key, uint64_t new_val);
19 uint64_t map_add    (map_t *map, void *key, uint64_t new_val);
20 uint64_t map_cas    (map_t *map, void *key, uint64_t expected_val, uint64_t new_val);
21 uint64_t map_replace(map_t *map, void *key, uint64_t new_val);
22 uint64_t map_remove (map_t *map, void *key);
23 uint64_t map_count  (map_t *map);
24 void     map_print  (map_t *map);
25 void     map_free   (map_t *map);
26
27 #endif//MAP_H