[project @ 2005-03-10 14:03:28 by simonmar]
[ghc-hetmet.git] / ghc / rts / Hash.h
1 /*-----------------------------------------------------------------------------
2  *
3  * (c) The GHC Team, 1999
4  *
5  * Prototypes for Hash.c
6  *
7  * -------------------------------------------------------------------------- */
8
9 typedef struct hashtable HashTable; /* abstract */
10
11 /* Hash table access where the keys are StgWords */
12 HashTable * allocHashTable    ( void );
13 void *      lookupHashTable ( HashTable *table, StgWord key );
14 void        insertHashTable ( HashTable *table, StgWord key, void *data );
15 void *      removeHashTable ( HashTable *table, StgWord key, void *data );
16
17 /* Hash table access where the keys are C strings (the strings are
18  * assumed to be allocated by the caller, and mustn't be deallocated
19  * until the corresponding hash table entry has been removed).
20  */
21 HashTable * allocStrHashTable ( void );
22
23 #define lookupStrHashTable(table, key)  \
24    (lookupHashTable(table, (StgWord)key))
25
26 #define insertStrHashTable(table, key, data)  \
27    (insertHashTable(table, (StgWord)key, data))
28
29 #define removeStrHashTable(table, key, data) \
30    (removeHashTable(table, (StgWord)key, data))
31
32 /* Freeing hash tables 
33  */
34 void freeHashTable ( HashTable *table, void (*freeDataFun)(void *) );