Hash works in debug but not release
This hash works fine in debug mode and my objects are added with no problem. In release mode the hash is different on the same exact string and even though the hash table should be empty at this point the check to see if the hashtable is empty at the computed index fails.
template <class T>
unsigned int HashTable<T>::Hash(const std::string &name)
const char *pBuffer = name.c_str();
unsigned int hashValue = 5381;
while (c = *pBuffer++)
hashValue = ((hashValue << 5) + hashValue) + c;
//Keep hash within range of table
return hashValue % m_tableSize;
After changing some code to catch an exception for this later and throw up a message box indicating the computed hash the stupid thing started working even though I did not change any of the hash code.
Twilight zone programming tonight.