-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathhashmap.h
More file actions
41 lines (34 loc) · 952 Bytes
/
hashmap.h
File metadata and controls
41 lines (34 loc) · 952 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
//
// Created by Once on 2019/8/11.
//
#ifndef DATALGORITHM_HASHMAP_H
#define DATALGORITHM_HASHMAP_H
// 使用整数作为关键字
typedef int Key;
// 记录值
typedef struct value{
int tag;
char message[128];
} Value;
// 记录结点
typedef struct hnode{
Key key;
Value value;
struct hnode *next;
} HNode;
// HashMap对外接口
typedef struct hashmap{
HNode *array; // 数组
int length; // 数组长度
int size; // 散列表的元素个数
} HashMap;
// HashMap函数声明
extern HashMap *hashmap_init(int length);
extern int hashmap_is_empty(HashMap *hashmap);
extern int hashmap_is_full(HashMap *hashmap);
extern int hashmap_add(HashMap *hashmap, Key key, Value *value);
extern int hashmap_delete(HashMap *hashmap, Key key);
extern HNode *hashmap_get(HashMap *hashmap, Key key);
extern void hashmap_traverse(HashMap *hashmap);
extern int hashmap_clear(HashMap *hashmap);
#endif //DATALGORITHM_HASHMAP_H