extra hash table implementation...might be worth trying
[IRC.git] / Robust / src / Runtime / DSTM / interface / clookup2.h
1 #ifndef _CLOOKUP_H_
2 #define _CLOOKUP_H_
3
4 #include <stdlib.h>
5 #include <stdio.h>
6
7 #define CLOADFACTOR 0.25
8 #define CHASH_SIZE 1024
9
10 struct chashentry {
11   void * ptr;
12   unsigned int key;
13 };
14
15 typedef struct chashtable {
16   struct chashentry *table;
17   unsigned int size;
18   unsigned int mask;
19   unsigned int numelements;
20   unsigned int capacity;
21   float loadfactor;
22 } chashtable_t;
23
24 /* Prototypes for hash*/
25 chashtable_t *chashCreate(unsigned int size, float loadfactor);
26 static unsigned int chashFunction(chashtable_t *table, unsigned int key);
27 void chashInsert(chashtable_t *table, unsigned int key, void *val);
28 void *chashSearch(chashtable_t *table, unsigned int key); //returns val, NULL if not found
29 void chashResize(chashtable_t *table, unsigned int newsize);
30 void chashDelete(chashtable_t *table);
31 /* end hash */
32
33 #endif
34