summaryrefslogtreecommitdiffstats
path: root/hashtbl.h
blob: 97c89a669ff43353905962872b9f1da97966c48c (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
#ifndef _HASHTBL_H_
#define _HASHTBL_H_

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct hashtbl
{
    size_t size;
    struct hashnode_s **nodes;
    unsigned int  (*hashfunc)(const char *);
} HASHTBL;

struct hashnode_s {
    char *key;
    void *data;
    struct hashnode_s *next;
};

/* function prototypes */
char *strdup(const char *);
HASHTBL *hashtbl_create(size_t, unsigned int (*hashfunc)(const char *));
void hashtbl_destroy(HASHTBL *);
int hashtbl_insert(HASHTBL *, const char *, void *);
int hashtbl_remove(HASHTBL *, const char *);
void *hashtbl_get(HASHTBL *, const char *);
int hashtbl_resize(HASHTBL *, size_t);

#endif