Tested functionality of llookup hash table with global hash table data structure
[IRC.git] / Robust / src / Runtime / DSTM / interface / llookup.h
1 #ifndef _LLOOKUP_H_
2 #define _LLOOKUP_H_
3
4 #include <stdlib.h>
5 #include <stdio.h>
6
7 #define LOADFACTOR 0.75
8 #define HASH_SIZE 100
9
10 typedef struct hashlistnode {
11         unsigned int oid;
12         unsigned int mid;
13         struct hashlistnode *next;
14 } lhashlistnode_t;
15
16 typedef struct hashtable {
17         lhashlistnode_t *table; // points to beginning of hash table
18         unsigned int size;
19         unsigned int numelements;
20         float loadfactor;
21 } lhashtable_t;
22
23 unsigned int lhashCreate(unsigned int size, float loadfactor);// returns 1 for success and 0 for failure
24 unsigned int lhashFunction(unsigned int oid); // returns 1 for success and 0 for failure
25 unsigned int lhashInsert(unsigned int oid, unsigned int mid); // returns 1 for success and 0 for failure
26 unsigned int lhashSearch(unsigned int oid); //returns mid, 0 if not found
27 unsigned int lhashRemove(unsigned int oid); //returns 0 if not success
28 unsigned int lhashResize(unsigned int newsize);  // returns 1 for success and 0 for failure
29
30 #endif