Add the prototypes for 3 hash implementations
[IRC.git] / Robust / src / Runtime / DSTM / interface / mlookup.h
1 #ifndef _MLOOKUP_H_
2 #define _MLOOKUP_H_
3
4 #define LOADFACTOR 0.75
5 #define HASH_SIZE 100
6
7 typedef struct hashlistnode {
8         unsigned int key;
9         void *val; //this can be cast to another type or used to point to a larger structure
10         struct hashlistnode *next;
11 } mhashlistnode_t;
12
13 typedef struct hashtable {
14         mhashlistnode_t *table; // points to beginning of hash table
15         unsigned int size;
16         unsigned int numelements;
17         float loadfactor;
18 } mhashtable_t;
19
20 /* Prototypes for hash*/
21 mhashtable_t *mhashCreate(unsigned int size, float loadfactor);
22 unsigned int mhashFunction(mhashtable_t *table, unsigned int key);
23 void mhashInsert(mhashtable_t *table, unsigned int key, void *val);
24 void *mhashSearch(mhashtable_t *table, unsigned int key); //returns val, NULL if not found
25 int mhashRemove(mhashtable_t *table, unsigned int key); //returns -1 if not found
26 void mhashResize(mhashtable_t *table, unsigned int newsize);
27 /* end hash */
28
29 #endif
30