-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpmdb.h
37 lines (29 loc) · 807 Bytes
/
pmdb.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
/***************************************************************
* PMDB: poor man's database
* create an array of hash buckets where each hash bucket is a
* binary search tree
*/
#ifndef PMDB_H
#define PMDB_H
typedef struct pmdb_elm
{
void * key;
void * data;
struct pmdb_elm *left, *right;
} pmdb_elm;
typedef struct pmdb
{
int (*hash)(void *);
int (*cmp)(void *,void *);
int (*free)(void *);
pmdb_elm ** buckets;
int hashSize;
int nEntries;
} pmdb;
pmdb * pmdb_create(int hashSize, int (*hash)(void *), int (*cmp)(void *,void *),int (*kfree)(void *));
int pmdb_insert(pmdb * db, void * key, void * data);
int pmdb_exists(pmdb *db, void * key);
void * pmdb_lookup(pmdb *db, void *key);
int pmdb_count_entries(pmdb *);
int pmdb_delete(pmdb *db, void *key); // not implemented!
#endif