Skip to main content
gamedev.net
🔒 Locked

decent hash function

Started by Turold 1 reply 750+ views
Original Post
Turold
Turold
I need a decent hash func, which converts a char string to an int. Is it somewhere in the standard libs or do I have to write my own? I use VS2005, C++.
ToohrVyk
ToohrVyk
It's in the C++ TR1, but chances are that your compiler doesn't have the TR1 available yet. See Boost.hash for a TR1-compatible hash primitive.
Evil Steve
Evil Steve
This is what I use. I can't remember where i got it from, I know I found the link on Google - anyone know where it's from?
u32 EID::Hash(const wchar_t* pData){   const wchar_t* pPtr = pData;   u32 nRet = 5381;   while(*pPtr)      nRet = ((nRet << 5) + nRet) + *pPtr++;   return nRet;}

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.