]>
Commit | Line | Data |
---|---|---|
1d8fe1f7 MR |
1 | #ifndef _HASHTABLE_H_ |
2 | #define _HASHTABLE_H_ | |
3 | ||
4 | #include <stdint.h> | |
5 | #include <stdbool.h> | |
6 | #include <stddef.h> | |
7 | ||
8 | #define TABLESIZE (1<<20) | |
9 | ||
10 | typedef uint64_t (*HashFunc)(const void*); | |
11 | typedef bool (*EqualFunc)(const void*, const void*); | |
12 | typedef struct _Hashtable Hashtable; | |
13 | ||
14 | uint64_t int_hash(const void*); | |
15 | uint64_t str_hash(const void*); | |
16 | uint64_t ptr_hash(const void*); | |
17 | bool int_equal(const void*, const void*); | |
18 | bool str_equal(const void*, const void*); | |
19 | bool ptr_equal(const void*, const void*); | |
20 | ||
21 | Hashtable* hash_table_create(HashFunc hf, EqualFunc ef); | |
22 | Hashtable* hash_table_create_full(HashFunc hf, EqualFunc ef, uint32_t size); | |
23 | void hash_table_destroy(Hashtable* ht); | |
24 | void hash_table_print(Hashtable* ht); | |
25 | bool hash_table_insert(Hashtable* ht, const void* key, void* obj); | |
26 | void* hash_table_lookup(Hashtable* ht, const void* key); | |
27 | void* hash_table_delete(Hashtable* ht, const void* key); | |
28 | ||
29 | #endif | |
30 |