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