forked from cnlohr/colorchord
-
Notifications
You must be signed in to change notification settings - Fork 0
/
chash.h
53 lines (37 loc) · 1.26 KB
/
chash.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#ifndef _CHASH_H
#define _CHASH_H
struct chashentry
{
const char * key;
void * value;
unsigned long hash;
};
struct chashlist
{
int length;
struct chashentry items[0];
};
struct chash
{
int entryCount;
int allowMultiple;
int bucketCountPlace;
struct chashentry * buckets;
};
struct chash * GenerateHashTable( int allowMultiple );
void ** HashTableInsert( struct chash * hash, const char * key, int dontDupKey );
//returns # of entries removed.
int HashTableRemove( struct chash * hash, const char * key );
//returns 1 if entry was removed, 0 otherwise.
int HashTableRemoveSpecific( struct chash * hash, const char * key, void * value );
void HashDestroy( struct chash * hash, int deleteKeys );
//Gets a pointer to the pointer to day, allowing you to read or modify the entry.
//NOTE: This only returns one of the elements if multiple keys are allowed.
void ** HashUpdateEntry( struct chash * hash, const char * key );
//Returns the entry itself, if none found, returns 0.
void * HashGetEntry( struct chash * hash, const char * key );
//Get list of entries that match a given key.
struct chashlist * HashGetAllEntries( struct chash * hash, const char * key );
//Can tolerate an empty list.
struct chashlist * HashProduceSortedTable( struct chash * hash );
#endif