forked from TrekMax/LearningMasteringAlgorithms-C
-
Notifications
You must be signed in to change notification settings - Fork 0
/
chtbl.h
43 lines (34 loc) · 870 Bytes
/
chtbl.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
/**
* @filename: chtbl.h
*
* @author: QinYUN575
*
* @create date: 2019/11/16
*
*
*
*/
#ifndef __CHTBL_H
#define __CHTBL_H
#include <stdlib.h>
#include "list.h"
/* 定义链式哈希表抽象数据结构 */
typedef struct CHTBL_
{
int buckets;
int (*h)(const void *key);
int (*match)(const void *key1, const void *key2);
int (*destroy)(void *data);
int size;
List *table;
} CHTbl;
/* Public Interface */
int chtbl_init(CHTbl *htbl, int buckets, int (*h)(const void *key),
int (*match)(const void *key1, const void *key2),
void (*destroy)(void *data));
void chtbl_destroy(CHTbl *htbl);
int chtbl_insert(CHTbl *htbl, const void *data);
int chtbl_remove(CHTbl *htbl, void **data);
int chtbl_lookup(CHTbl *htbl, void **data);
#define chtbl_size(htbl) ((htbl)->size)
#endif