I have a project where I have to analyze 3 different hashing functions. I cannot get the cyclic shift hash to work with a bitwise OR. Everything looks fine to me am I doing something wrong?
int Hash::hash(string key) {
unsigned int h = 0;
for(int i =0; i < key.length(); i++) {
h = (h << 5) | (h >> 27);
h += static_cast<unsigned int>(key[i]);
}
return (static_cast<int>(h) % NUM_BUCKETS);
}
I get
Unhandled exception at 0x7082212e (msvcp90d.dll) in CS400_HW3.exe: 0xC0000005: Access violation reading location 0xcccccce4.
at line 4. I'm using M$ Visual Studio 2008 pro.