hash function

can anyone please explain what is happening in this whole hash function
1
2
3
4
5
6
7
 int BSTHashtable:: hash(string& s)
{
    unsigned int hashVal = 0;
    for (unsigned int i = 0; i < s.length(); i++)
        hashVal ^= (hashVal << 5) + (hashVal >> 2) + s[i];
    return hashVal % size;
}
A hash value is generated based on the contents of the string. If you don't understand what the bit-wise operators are doing, now might be a good time to review them.

https://en.wikipedia.org/wiki/Hash_function
that i know whats the line num 5 is doing while converting the bits into strings
Topic archived. No new replies allowed.