X-Git-Url: http://plrg.eecs.uci.edu/git/?p=iotcloud.git;a=blobdiff_plain;f=version2%2Fsrc%2FC%2Fhashtable.h;h=6107e339c3ea972e5997374708f999cb7b4d2b5c;hp=aca3361eb912b6e017f97a95bb96f372d242fe14;hb=f818627d0fc1f3c106684c1daff1cb96edc087db;hpb=34ca5d4113dbbd0b5342abd280e2f9e11e7cd3b7;ds=sidebyside diff --git a/version2/src/C/hashtable.h b/version2/src/C/hashtable.h index aca3361..6107e33 100644 --- a/version2/src/C/hashtable.h +++ b/version2/src/C/hashtable.h @@ -70,7 +70,7 @@ public: * @param factor Sets the percentage full before the hashtable is * resized. Default ratio 0.5. */ - Hashtable(unsigned int initialcapacity = 1024, double factor = 0.5) { + Hashtable(unsigned int initialcapacity = 32, double factor = 0.5) { // Allocate space for the hash table table = (struct Hashlistnode<_Key, _Val> *)ourcalloc(initialcapacity, sizeof(struct Hashlistnode<_Key, _Val>)); zero = NULL; @@ -83,15 +83,15 @@ public: tail = list = NULL; } -Hashtable<_Key, _Val, _KeyInt, _Shift, hash_function, equals> * clone() { - Hashtable<_Key, _Val, _KeyInt, _Shift, hash_function, equals> * ctable = new Hashtable<_Key, _Val, _KeyInt, _Shift, hash_function, equals> (capacity, loadfactor); - struct Hashlistnode<_Key, _Val> * ptr = list; - while (ptr != NULL) { - ctable->put(ptr->key, ptr->val); - ptr = ptr->next; + Hashtable<_Key, _Val, _KeyInt, _Shift, hash_function, equals> *clone() { + Hashtable<_Key, _Val, _KeyInt, _Shift, hash_function, equals> *ctable = new Hashtable<_Key, _Val, _KeyInt, _Shift, hash_function, equals> (capacity, loadfactor); + struct Hashlistnode<_Key, _Val> *ptr = list; + while (ptr != NULL) { + ctable->put(ptr->key, ptr->val); + ptr = ptr->next; + } + return ctable; } - return ctable; -} /** @brief Hash table destructor */ @@ -261,6 +261,7 @@ Hashtable<_Key, _Val, _KeyInt, _Shift, hash_function, equals> * clone() { tail = search; else list->prev = search; + list = search; Size++; return (_Val) 0; }