+/** @file hashtable.h
+ * @brief Hashtable. Standard chained bucket variety.
+ */
+
#ifndef HASHTABLE_H
#define HASHTABLE_H
free(table);
}
+ /** Reset the table to its initial state. */
void reset() {
for(int i=0;i<capacity;i++) {
struct hashlistnode<_Key,_Val> * bin = table[i];
size=0;
}
+ /** Put a key value pair into the table. */
void put(_Key key, _Val val) {
if(size > threshold) {
//Resize
table[(((_KeyInt)key)&mask)>>_Shift]=newptr;
}
+ /** Lookup the corresponding value for the given key. */
_Val get(_Key key) {
struct hashlistnode<_Key,_Val> *search = table[(((_KeyInt)key) & mask)>>_Shift];
return (_Val)0;
}
+ /** Check whether the table contains a value for the given key. */
bool contains(_Key key) {
struct hashlistnode<_Key,_Val> *search = table[(((_KeyInt)key) & mask)>>_Shift];
return false;
}
+ /** Resize the table. */
void resize(unsigned int newsize) {
struct hashlistnode<_Key,_Val> ** oldtable = table;
struct hashlistnode<_Key,_Val> ** newtable;