int32_t BKDRHash(const std::string &name){
int32_t
hash =
0, seed =
131;
for (uint32_t i =
0; i < name.length(); i++){
hash =
hash * seed + name[i];
//transform
hash into
131 system
}
//to get positive number by using
hash &
0111 111 111 1111b
}
//
hash function
2
int32_t APHash(const std::string &name){
int32_t
hash =
0;
for (uint32_t i =
0; i < name.length(); i++){
if (i %
2){
hash ^= (~((
hash <<
11) ^ (name[i]) ^ (
hash >>
5)));
}
else {
hash ^= ((
hash <<
7) ^ (name[i]) ^ (
hash >>
3));
}
}
return (
hash &
0x7fffffff);
}
转载请注明原文地址: https://ju.6miu.com/read-1303885.html