From 636584b49d002f709cb450cb144e60f0492cb3fe Mon Sep 17 00:00:00 2001 From: adash Date: Thu, 1 Mar 2007 23:57:35 +0000 Subject: [PATCH] Add the prototypes for 3 hash implementations --- Robust/src/Runtime/DSTM/interface/clookup.h | 30 ++++++++++++++++++++ Robust/src/Runtime/DSTM/interface/llookup.h | 31 +++++++++++++++++++++ Robust/src/Runtime/DSTM/interface/mlookup.h | 30 ++++++++++++++++++++ 3 files changed, 91 insertions(+) create mode 100644 Robust/src/Runtime/DSTM/interface/clookup.h create mode 100644 Robust/src/Runtime/DSTM/interface/llookup.h create mode 100644 Robust/src/Runtime/DSTM/interface/mlookup.h diff --git a/Robust/src/Runtime/DSTM/interface/clookup.h b/Robust/src/Runtime/DSTM/interface/clookup.h new file mode 100644 index 00000000..3f99ca24 --- /dev/null +++ b/Robust/src/Runtime/DSTM/interface/clookup.h @@ -0,0 +1,30 @@ +#ifndef _CLOOKUP_H_ +#define _CLOOKUP_H_ + +#define LOADFACTOR 0.75 +#define HASH_SIZE 100 + +typedef struct hashlistnode { + unsigned int key; + void *val; //this can be cast to another type or used to point to a larger structure + struct hashlistnode *next; +} cachehashlistnode_t; + +typedef struct hashtable { + cachehashlistnode_t *table; // points to beginning of hash table + unsigned int size; + unsigned int numelements; + float loadfactor; +} cachehashtable_t; + +/* Prototypes for hash*/ +cachehashtable_t *cachehashCreate(unsigned int size, float loadfactor); +unsigned int cachehashFunction(cachehashtable_t *table, unsigned int key); +void cachehashInsert(cachehashtable_t *table, unsigned int key, void *val); +void *cachehashSearch(cachehashtable_t *table, unsigned int key); //returns val, NULL if not found +int cachehashRemove(cachehashtable_t *table, unsigned int key); //returns -1 if not found +void cachehashResize(cachehashtable_t *table, unsigned int newsize); +/* end hash */ + +#endif + diff --git a/Robust/src/Runtime/DSTM/interface/llookup.h b/Robust/src/Runtime/DSTM/interface/llookup.h new file mode 100644 index 00000000..9cc94529 --- /dev/null +++ b/Robust/src/Runtime/DSTM/interface/llookup.h @@ -0,0 +1,31 @@ +#ifndef _LLOOKUP_H_ +#define _LLOOKUP_H_ + +#define LOADFACTOR 0.75 +#define HASH_SIZE 100 + +typedef struct hashlistnode { + unsigned int oid; + unsigned int mid; + void *val;// points to the object header structure + struct hashlistnode *next; +} lhashlistnode_t; + +typedef struct hashtable { + lhashlistnode_t *table; // points to beginning of hash table + unsigned int size; + unsigned int numelements; + float loadfactor; +} lhashtable_t; + +/* Prototypes for hash*/ +lhashtable_t *lhashCreate(unsigned int size, float loadfactor); +unsigned int lhashFunction(lhashtable_t *table, unsigned int oid); +void lhashInsert(lhashtable_t *table, unsigned int oid, void *val, unsigned int mid); +void *lhashSearch(lhashtable_t *table, unsigned int oid); //returns val, NULL if not found +int lhashRemove(lhashtable_t *table, unsigned int oid); //returns -1 if not found +void lhashResize(lhashtable_t *table, unsigned int newsize); +/* end hash */ + +#endif + diff --git a/Robust/src/Runtime/DSTM/interface/mlookup.h b/Robust/src/Runtime/DSTM/interface/mlookup.h new file mode 100644 index 00000000..e5c545d2 --- /dev/null +++ b/Robust/src/Runtime/DSTM/interface/mlookup.h @@ -0,0 +1,30 @@ +#ifndef _MLOOKUP_H_ +#define _MLOOKUP_H_ + +#define LOADFACTOR 0.75 +#define HASH_SIZE 100 + +typedef struct hashlistnode { + unsigned int key; + void *val; //this can be cast to another type or used to point to a larger structure + struct hashlistnode *next; +} mhashlistnode_t; + +typedef struct hashtable { + mhashlistnode_t *table; // points to beginning of hash table + unsigned int size; + unsigned int numelements; + float loadfactor; +} 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 */ + +#endif + -- 2.34.1