1 /*-----------------------------------------------------------------------------
3 * (c) The GHC Team, 1999
5 * Prototypes for Hash.c
7 * -------------------------------------------------------------------------- */
12 typedef struct hashtable HashTable; /* abstract */
14 /* Hash table access where the keys are StgWords */
15 HashTable * allocHashTable ( void );
16 void * lookupHashTable ( HashTable *table, StgWord key );
17 void insertHashTable ( HashTable *table, StgWord key, void *data );
18 void * removeHashTable ( HashTable *table, StgWord key, void *data );
20 /* Hash table access where the keys are C strings (the strings are
21 * assumed to be allocated by the caller, and mustn't be deallocated
22 * until the corresponding hash table entry has been removed).
24 HashTable * allocStrHashTable ( void );
26 #define lookupStrHashTable(table, key) \
27 (lookupHashTable(table, (StgWord)key))
29 #define insertStrHashTable(table, key, data) \
30 (insertHashTable(table, (StgWord)key, data))
32 #define removeStrHashTable(table, key, data) \
33 (removeHashTable(table, (StgWord)key, data))
35 /* Hash tables for arbitrary keys */
36 typedef int HashFunction(HashTable *table, StgWord key);
37 typedef int CompareFunction(StgWord key1, StgWord key2);
38 HashTable * allocHashTable_(HashFunction *hash, CompareFunction *compare);
39 int hashWord(HashTable *table, StgWord key);
40 int hashStr(HashTable *table, char *key);
42 /* Freeing hash tables
44 void freeHashTable ( HashTable *table, void (*freeDataFun)(void *) );
46 void exitHashTable ( void );