1998-12-27 00:33:51 +08:00
|
|
|
#ifndef H_HASH
|
|
|
|
#define H_HASH
|
|
|
|
|
|
|
|
typedef struct hashTable_s * hashTable;
|
|
|
|
|
1998-12-27 02:31:45 +08:00
|
|
|
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, void * data);
|
1998-12-27 00:33:51 +08:00
|
|
|
void htFree(hashTable ht);
|
1998-12-27 02:31:45 +08:00
|
|
|
/* returns 0 on success, 1 if the item is not found. tableKey may be NULL */
|
|
|
|
int htGetEntry(hashTable ht, const void * key, void *** data, int * dataCount,
|
|
|
|
void ** tableKey);
|
1998-12-27 00:33:51 +08:00
|
|
|
/* returns 1 if the item is present, 0 otherwise */
|
1998-12-27 02:31:45 +08:00
|
|
|
int htHasEntry(hashTable ht, const void * key);
|
1998-12-27 00:33:51 +08:00
|
|
|
|
|
|
|
#endif
|