-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhash.h
More file actions
46 lines (40 loc) · 902 Bytes
/
hash.h
File metadata and controls
46 lines (40 loc) · 902 Bytes
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
#ifndef HASH_H
#define HASH_H
typedef struct Bucket {
struct Bucket* link;
struct Bucket* listLink;
void* key;
void* val;
} Bucket;
typedef int (*CmpFunc)(void*, void*);
typedef unsigned int (*HashFunc)(void*);
typedef void* (*DupFunc)(void*);
typedef void (*FreeFunc)(void*);
typedef struct DataHandlr {
HashFunc hashCode;
CmpFunc cmp;
DupFunc dup;
FreeFunc free;
} DataHandlr;
typedef struct Map {
int cap;
int size;
Bucket* link;
DataHandlr key;
DataHandlr val;
Bucket buckets[];
} Map;
Bucket* newLink();
Map* newMap(int cap, DataHandlr key);
Map* newStrMap(int cap);
Map* newIntMap(int cap);
Map* newIntPtrMap(int cap);
Map* newStrRefMap(int cap);
void mPut(Map* m, void *key, void* val);
void* mGet(Map* m, void *key);
void mDel(Map* m, void *key);
void mGetKeys(Map* m, void **array);
void destroyMap(Map* m);
void dummyFree(void*);
void* dummyDup(void*);
#endif