testsuite: attempt fixing fallout from 089b72f52
[ghc.git] / rts / Hash.h
1 /*-----------------------------------------------------------------------------
2 *
3 * (c) The GHC Team, 1999
4 *
5 * Prototypes for Hash.c
6 *
7 * -------------------------------------------------------------------------- */
8
9 #ifndef HASH_H
10 #define HASH_H
11
12 #include "BeginPrivate.h"
13
14 typedef struct hashtable HashTable; /* abstract */
15
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 );
21
22 int keyCountHashTable (HashTable *table);
23
24 // Puts up to szKeys keys of the hash table into the given array. Returns the
25 // actual amount of keys that have been retrieved.
26 //
27 // If the table is modified concurrently, the function behavior is undefined.
28 //
29 int keysHashTable(HashTable *table, StgWord keys[], int szKeys);
30
31 /* Hash table access where the keys are C strings (the strings are
32 * assumed to be allocated by the caller, and mustn't be deallocated
33 * until the corresponding hash table entry has been removed).
34 */
35 HashTable * allocStrHashTable ( void );
36
37 #define lookupStrHashTable(table, key) \
38 (lookupHashTable(table, (StgWord)key))
39
40 #define insertStrHashTable(table, key, data) \
41 (insertHashTable(table, (StgWord)key, data))
42
43 #define removeStrHashTable(table, key, data) \
44 (removeHashTable(table, (StgWord)key, data))
45
46 /* Hash tables for arbitrary keys */
47 typedef int HashFunction(HashTable *table, StgWord key);
48 typedef int CompareFunction(StgWord key1, StgWord key2);
49 HashTable * allocHashTable_(HashFunction *hash, CompareFunction *compare);
50 int hashWord(HashTable *table, StgWord key);
51 int hashStr(HashTable *table, char *key);
52
53 /* Freeing hash tables
54 */
55 void freeHashTable ( HashTable *table, void (*freeDataFun)(void *) );
56
57 void exitHashTable ( void );
58
59 #include "EndPrivate.h"
60
61 #endif /* HASH_H */