start of new file
[IRC.git] / Robust / src / Runtime / DSTM / interface / mlookup.h
index e5c545d256bdf040cf1777e91249a8f5c0210f85..aec887981fdc6b923c9aea8e8f336e37aafbbcf2 100644 (file)
@@ -1,30 +1,35 @@
 #ifndef _MLOOKUP_H_
 #define _MLOOKUP_H_
 
-#define LOADFACTOR 0.75
+#include <stdlib.h>
+#include <stdio.h>
+#include <pthread.h>
+
+#define LOADFACTOR 0.5
 #define HASH_SIZE 100
 
-typedef struct hashlistnode {
+typedef struct mhashlistnode {
        unsigned int key;
        void *val; //this can be cast to another type or used to point to a larger structure
-       struct hashlistnode *next;
+       struct mhashlistnode *next;
 } mhashlistnode_t;
 
-typedef struct hashtable {
+typedef struct mhashtable {
        mhashlistnode_t *table; // points to beginning of hash table
        unsigned int size;
        unsigned int numelements;
        float loadfactor;
+       pthread_mutex_t locktable;
 } mhashtable_t;
 
-/* Prototypes for hash*/
-mhashtable_t *mhashCreate(unsigned int size, float loadfactor);
-unsigned int mhashFunction(mhashtable_t *table, unsigned int key);
-void mhashInsert(mhashtable_t *table, unsigned int key, void *val);
-void *mhashSearch(mhashtable_t *table, unsigned int key); //returns val, NULL if not found
-int mhashRemove(mhashtable_t *table, unsigned int key); //returns -1 if not found
-void mhashResize(mhashtable_t *table, unsigned int newsize);
-/* end hash */
+unsigned int mhashCreate(unsigned int size, float loadfactor);
+unsigned int mhashFunction(unsigned int key);
+unsigned mhashInsert(unsigned int key, void *val);
+void *mhashSearch(unsigned int key); //returns val, NULL if not found
+unsigned int mhashRemove(unsigned int key); //returns -1 if not found
+unsigned int mhashResize(unsigned int newsize);
+unsigned int *mhashGetKeys(unsigned int *numKeys);
+void mhashPrint();
 
 #endif