-
Notifications
You must be signed in to change notification settings - Fork 0
/
hashtable.h
33 lines (26 loc) · 883 Bytes
/
hashtable.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#ifndef HASHTABLE_H
#define HASHTABLE_H
struct key {
const void *key;
int len;
};
struct hashtable_elem {
char used;
struct key key;
void *value;
struct hashtable_elem *next;
};
struct hashtable {
int size;
struct hashtable_elem *table;
};
struct hashtable *create_hashtable(int size);
void free_hashtable(struct hashtable *hashtable);
void hashtable_inserts(struct hashtable *hashtable, const char *key, void *value);
void hashtable_insert(struct hashtable *hashtable, const void *key, int keylen, void *value);
void *hashtable_gets(struct hashtable *hashtable, const char *key);
void *hashtable_get(struct hashtable *hashtable, const void *key, int keylen);
void hashtable_removes(struct hashtable *hashtable, const char *key);
void hashtable_remove(struct hashtable *hashtable, const void *key, int keylen);
void dump_hashtable(struct hashtable *hashtable);
#endif