]> pd.if.org Git - nbds/blob - include/ht.h
Initial commit
[nbds] / include / ht.h
1 /* 
2  * Written by Josh Dybnis and released to the public domain, as explained at
3  * http://creativecommons.org/licenses/publicdomain
4  */
5 #ifndef HT_H
6 #define HT_H
7
8 #include "common.h"
9
10 #define DOES_NOT_EXIST 0
11
12 #define HT_EXPECT_NOT_EXISTS ( 0)
13 #define HT_EXPECT_EXISTS     (-1)
14 #define HT_EXPECT_WHATEVER   (-2)
15
16 typedef struct hash_table_i *hash_table_t;
17
18 hash_table_t *ht_alloc (void);
19 void ht_free (hash_table_t *ht);
20 int64_t ht_get (hash_table_t *ht, const char *key, uint32_t len);
21 int64_t ht_compare_and_set (hash_table_t *ht, const char *key, uint32_t key_len, int64_t expected_val, int64_t val);
22 int64_t ht_remove (hash_table_t *ht, const char *key, uint32_t len);
23 uint64_t ht_count (hash_table_t *ht);
24
25 #endif//HT_H