[C/C++]BKDRHash
将字符串Hash成整型存储经常用到BKDRHash算法
uint64_t BKDRHash(const char *pszKey)
{
uint64_t seed = 131;
register uint64_t uCode=0;
while(pszKey[0])
{
uCode = uCode *seed + (unsigned char)pszKey[0];
pszKey++;
}
return uCode;
}
选择了64位的key,减少冲突的概率。
浙公网安备 33010602011771号