forked from gozfree/gear-lib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlibhash.h
48 lines (35 loc) · 1.01 KB
/
libhash.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/******************************************************************************
* Copyright (C) 2014-2015
* file: libhash.h
* author: gozfree <[email protected]>
* created: 2015-05-10 00:42
* updated: 2015-05-10 00:42
******************************************************************************/
#ifndef LIBHASH_H
#define LIBHASH_H
#include <libmacro.h>
#ifdef __cplusplus
extern "C" {
#endif
struct hash {
char *name;
struct hlist_head *list;
int bucket_size;
void (*destory)(void *value);
};
struct hash_entry {
struct hlist_node entry;
char *key;
void *value;
};
void *hash_get(struct hash *dict, const char *key);
void hash_set(struct hash *dict, const char *key, void *value);
void hash_del(struct hash *dict, const char *key);
void *hash_get_and_del(struct hash *dict, const char *key);
struct hash *hash_create(int bucket_size);
void hash_destroy(struct hash *dict);
void hash_set_destory(struct hash *dict, void (*destory)(void *value));
#ifdef __cplusplus
}
#endif
#endif