]> pd.if.org Git - nbds/blob - include/map.h
generic interface for map-like data structures
[nbds] / include / map.h
1 #ifndef MAP_H
2 #define MAP_H
3
4 typedef struct map map_t;
5 typedef enum stat { MAP_STAT_COUNT } map_stat_e;
6 typedef enum { MAP_TYPE_HASHTABLE, MAP_TYPE_SKIPLIST, MAP_TYPE_LIST } map_type_e;
7
8 map_t *  map_alloc  (map_type_e map_type);
9 void     map_free   (map_t *map);
10 void     map_print  (map_t *map);
11 uint64_t map_stat   (map_t *map, map_stat_e stat_type);
12
13 uint64_t map_get    (map_t *map, const void *key_data, uint32_t key_len);
14 uint64_t map_set    (map_t *map, const void *key_data, uint32_t key_len, uint64_t new_val);
15 uint64_t map_add    (map_t *map, const void *key_data, uint32_t key_len, uint64_t new_val);
16 uint64_t map_cas    (map_t *map, const void *key_data, uint32_t key_len, uint64_t expected_val, uint64_t new_val);
17 uint64_t map_replace(map_t *map, const void *key_data, uint32_t key_len, uint64_t new_val);
18 uint64_t map_remove (map_t *map, const void *key_data, uint32_t key_len);
19
20 #endif//MAP_H