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
|
#ifndef H_HASH
#define H_HASH
typedef struct hashTable_s * hashTable;
#ifdef __cplusplus
extern "C" {
#endif
typedef unsigned int (*hashFunctionType)(const void * string);
typedef int (*hashEqualityType)(const void * key1, const void * key2);
unsigned int hashFunctionString(const void * string);
int hashEqualityString(const void * key1, const void * key2);
/* if keySize > 0, the key is duplicated within the table (which costs
memory, but may be usefull anyway */
hashTable htCreate(int numBuckets, int keySize, hashFunctionType fn,
hashEqualityType eq);
void htAddEntry(hashTable ht, const void * key, const void * data);
void htFree( /*@only@*/ hashTable ht);
/* returns 0 on success, 1 if the item is not found. tableKey may be NULL */
int htGetEntry(hashTable ht, const void * key, /*@out@*/ const void *** data,
/*@out@*/ int * dataCount, /*@out@*/const void ** tableKey);
/* returns 1 if the item is present, 0 otherwise */
int htHasEntry(hashTable ht, const void * key);
#ifdef __cplusplus
}
#endif
#endif
|