]> pd.if.org Git - nbds/blobdiff - include/map.h
use a vtable approach for generic map interface
[nbds] / include / map.h
index d670c35d17d877191fadd55938e8c87974c00575..44b9d27ea979570be69760a4cc7afb6d368f6a4c 100644 (file)
@@ -2,19 +2,22 @@
 #define MAP_H
 
 typedef struct map map_t;
-typedef enum stat { MAP_STAT_COUNT } map_stat_e;
-typedef enum { MAP_TYPE_HASHTABLE, MAP_TYPE_SKIPLIST, MAP_TYPE_LIST } map_type_e;
 
-map_t *  map_alloc  (map_type_e map_type);
-void     map_free   (map_t *map);
-void     map_print  (map_t *map);
-uint64_t map_stat   (map_t *map, map_stat_e stat_type);
+typedef const struct map_impl *map_type_t;
+
+extern map_type_t MAP_TYPE_HASHTABLE;
+extern map_type_t MAP_TYPE_SKIPLIST;
+extern map_type_t MAP_TYPE_LIST;
 
+map_t *  map_alloc  (map_type_t map_type);
 uint64_t map_get    (map_t *map, const void *key_data, uint32_t key_len);
 uint64_t map_set    (map_t *map, const void *key_data, uint32_t key_len, uint64_t new_val);
 uint64_t map_add    (map_t *map, const void *key_data, uint32_t key_len, uint64_t new_val);
 uint64_t map_cas    (map_t *map, const void *key_data, uint32_t key_len, uint64_t expected_val, uint64_t new_val);
 uint64_t map_replace(map_t *map, const void *key_data, uint32_t key_len, uint64_t new_val);
 uint64_t map_remove (map_t *map, const void *key_data, uint32_t key_len);
+uint64_t map_count  (map_t *map);
+void     map_print  (map_t *map);
+void     map_free   (map_t *map);
 
 #endif//MAP_H