a. Change queue implementation to linked list
[IRC.git] / Robust / src / Runtime / DSTM / interface / prelookup.h
1 #ifndef _PRELOOKUP_H_
2 #define _PRELOOKUP_H_
3
4 #include <stdlib.h>
5 #include <stdio.h>
6 #include <pthread.h>
7
8 #define LOADFACTOR 0.75
9 #define HASH_SIZE 100
10
11 typedef struct prehashlistnode {
12         unsigned int key;
13         void *val; //this can be cast to another type or used to point to a larger structure
14         struct prehashlistnode *next;
15 } prehashlistnode_t;
16
17 typedef struct prehashtable {
18         prehashlistnode_t *table;       // points to beginning of hash table
19         unsigned int size;
20         unsigned int numelements;
21         float loadfactor;
22         pthread_mutex_t lock;
23 } prehashtable_t;
24
25 /* Prototypes for hash*/
26 unsigned int prehashCreate(unsigned int size, float loadfactor);
27 unsigned int prehashFunction(unsigned int key);
28 unsigned int prehashInsert(unsigned int key, void *val);
29 void *prehashSearch(unsigned int key); //returns val, NULL if not found
30 unsigned int prehashRemove(unsigned int key); //returns -1 if not found
31 unsigned int prehashResize(unsigned int newsize);
32 /* end hash */
33
34 #endif
35