-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhashtable.h
29 lines (20 loc) · 982 Bytes
/
hashtable.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
#ifndef _HASHTABLE_INCLUDED_
#define _HASHTABLE_INCLUDED_
typedef struct hashtable Hashtable;
/* ht_create - create new hashtable - returns NULL if error (malloc) */
Hashtable *ht_create(unsigned long nbuckets);
/* ht_insert - add an entry to hashtable
* returns 1 if successful, 0 if error (malloc)
* returns 1 if if replaced value associated with key */
int ht_insert(Hashtable *ht, char *key, void *value);
/* ht_lookup - look up key in hashtable, returning value or NULL */
void *ht_lookup(Hashtable *ht, char *key);
/* ht_remove - remove entry associated with key from the table */
void ht_remove(Hashtable *ht, char *key);
/* ht_keylist - return list of keys in the table
* upon return, N has number of items in array of pointers
* if allocation failure of array of pointers, N will be -1
* return value is array of pointers that must be freed after use */
char **ht_keylist(Hashtable *ht, int *N);
void ht_free(Hashtable *ht);
#endif /* _HASHTABLE_INCLUDED_ */