I am looking for a hash function in c++ to hash a string to an int. I used CMapStringToPtr but it has a function called “GetNextAssoc” that allows retrieving the key as string, meaning that the string must be stored and it gets so much memory.
Is there any other hash function that gets less memory and does not store the string?
I am looking for a hash function in c++ to hash a string to
Share
C++ has a built in hash function for this purpose – its used for all STL hash containers.
std::hashPS: you can make your own too, just pass the string by const reference and cycle through its characters one by one, adding them to an integer, then mod by some value 🙂