-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhash.h
38 lines (30 loc) · 826 Bytes
/
hash.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
#ifndef HASH_H
#define HASH_H
#include <stdbool.h>
struct hashnode
{
int key1;
int key2;
void *value;
struct hashnode *next;
};
typedef unsigned (*hash_proc)(int key1, int key2);
struct hash
{
hash_proc hash;
unsigned size;
unsigned num_buckets;
struct hashnode *buckets;
bool *buckets_in_use;
bool freeb;
bool freeh;
};
void *hashnode_delete(struct hash *h, int key1, int key2);
void *hashnode_set(struct hash *h, int key1, int key2, void *value);
void *hashnode_get(const struct hash *h, int key1, int key2);
struct hash *hash_new(hash_proc hash, unsigned num_buckets);
void hash_init(struct hash *h, hash_proc hash, unsigned num_buckets);
void hash_delete(struct hash *h, bool free_values);
void hash_clear(struct hash *h, bool free_values);
unsigned hash_size(const struct hash *h);
#endif /* HASH_H */