X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=hashtable.h;fp=hashtable.h;h=75d68f2c97793bd3208aedea5a216cc58ad68513;hb=b118d83f84a47a6ac778ed8ea43030d477b0bc9c;hp=5d9e2d620045924a20db2b3bea491622bfe1ebd0;hpb=c47ea1e8fc71e7934d6a670802247d41a603128a;p=cdsspec-compiler.git diff --git a/hashtable.h b/hashtable.h index 5d9e2d6..75d68f2 100644 --- a/hashtable.h +++ b/hashtable.h @@ -9,10 +9,10 @@ #include template - struct hashlistnode { - _Key key; - _Val val; - struct hashlistnode<_Key,_Val, _malloc, _calloc, _free> *next; +struct hashlistnode { + _Key key; + _Val val; + struct hashlistnode<_Key,_Val, _malloc, _calloc, _free> *next; void * operator new(size_t size) { return _malloc(size); @@ -29,11 +29,12 @@ template class HashTable { public: @@ -118,13 +119,13 @@ template threshold) { + if (size > threshold) { //Resize - unsigned int newsize = capacity << 1; - resize(newsize); - } + unsigned int newsize = capacity << 1; + resize(newsize); + } - struct hashlistnode<_Key,_Val, _malloc, _calloc, _free> *ptr = table[(((_KeyInt)key) & mask)>>_Shift]; + struct hashlistnode<_Key,_Val, _malloc, _calloc, _free> *ptr = table[(((_KeyInt)key) & mask)>>_Shift]; size++; struct hashlistnode<_Key,_Val, _malloc, _calloc, _free> *search = ptr;