unsigned int getHashCode(CString str)
{
if(str.isEmpty())
return 0;
int len = str.GetLength();
unsigned int ihash = 0;
unsigned int g = 0;
for(int i = 0; i < len;++i)
{
byte temp = (byte)(str.GetAt(i));
ihash = (ihash <<4) + temp;
g = (unsigned int)(ihash & 0xf0000000);
if(g != 0)
{
ihash ^= (g>>24);
ihash ^= g;
}
}
return ihash
}
哈希函数学习
最新推荐文章于 2024-07-19 20:47:05 发布