blob: 357e38a49e9d270a2684cbfb701406fa56d8b1ce (
plain)
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
|
#ifndef HASH_TABLE_H
#define HASH_TABLE_H
#include <array.h>
#define DEFAULT_HT_SIZE 500
typedef struct PAIR_STRUCT {
char *key;
void *v;
} pair_t;
typedef struct NODE_STRUCT {
char *key;
void *v;
struct NODE_STRUCT *next;
} node_t;
typedef struct {
node_t *head;
node_t *tail;
} sll_t;
typedef struct {
sll_t **buckets;
size_t size;
} ht_t;
node_t *init_node(char *key, void *v);
void sll_push(sll_t *sll, char *key, void *v);
void sll_delete(sll_t *sll, char *key);
sll_t *sll_free(void *x, void (*freefunc)(void *));
void ht_insert(ht_t *ht, char *key, void *value);
void ht_delete(ht_t *ht, char *key);
void *ht_get(ht_t *ht, char *key);
ht_t *init_ht(size_t size);
#endif
|