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