-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathohtbl.h
42 lines (36 loc) · 973 Bytes
/
ohtbl.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
/**
* @filename: ohtbl.c
*
* @author: QinYUN575
*
* @create date: 2019/11/18
*
*
*
*/
#ifndef __OHTBL_H
#define __OHTBL_H
#include <stdlib.h>
/* 定义开地址式抽象数据结构类型 */
typedef struct OHTbl_
{
int positions;
void *vacated;
int (*h1)(const void *data);
int (*h2)(const void *data);
int (*match)(const void *key1, const void *key2);
void (*destroy)(void *data);
int size;
void **table;
} OHTbl;
/* Public Interface */
int ohtbl_init(OHTbl *htbl, int positions,
int (*h1)(const void *data), int (*h2)(const void *data),
int (*match)(const void *key1, const void *key2),
void (*destroy)(const void *data));
void ohtbl_destroy(OHTbl *htbl);
int ohtbl_insert(OHTbl *htbl, void *data);
int ohtbl_remove(OHTbl *htbl, void **data);
int ohtbl_lookup(OHTbl *htbl, void **data);
#define ohtbl_size(htbl) ((htbl)->size)
#endif