-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhashmap.h
More file actions
74 lines (59 loc) · 1.03 KB
/
hashmap.h
File metadata and controls
74 lines (59 loc) · 1.03 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*
a very simple hashmap designed for C. This hash map
can store integers only.
author: Sefler Zhou
date: 2010-6-11
*/
#ifndef HASH_MAP
#define HASH_MAP
// return this if not found
#define NOT_FOUND -1
typedef struct
{
char* str;
int value;
}bucket;
/*
structure of the hashmap
*/
typedef struct
{
bucket** table;
int size;
int maxSize;
}hash_map;
/*
initiate the hashmap
parameters
map: the hashmap to be initiated
size: the initiate size of the hashmap.
*/
void initiateHashMap(hash_map* map, int size);
/*
expansion the hashmap
*/
void expansionHashMap(hash_map** map);
/*
put in data
parameters
str: the key string
value: the value to be stored
map: the map the to operate
*/
void putInHashMap(const char* str, int value, hash_map* map);
/*
fetch data
parameters
str: the key string
map: the map the to operate
*/
int fetchData(const char* str, hash_map* map);
/*
dismiss hashmap
*/
void dismissHashMap(hash_map* map);
/*
Extract the hash key from the string
*/
int getKey(const char* str, int mSize);
#endif