int bkdr_hash(string str) {
const int seed = 131;
int hash = 0;
for (int i = 0; i < str.length(); i++) {
hash = hash * seed + (int)str[i];
}
return hash & 0x7FFFFFFF;
}
int djb_hash(string str) {
int hash = 5381;
for (int i = 0; i < str.length(); i++) {
hash += (hash << 5) + (int)str[i];
}
return hash & 0x7FFFFFFF;
}
int elf_hash(string str) {
int hash = 0;
int x = 0;
for (int i = 0; i < str.length(); i++) {
hash = (hash << 4) + (int)str[i];
if ((x & hash & 0xF0000000L) != 0) {
hash ^= x >> 24;
hash &= ~x;
}
}
return hash & 0x7FFFFFFF;
}
int fnv_hash(string str) {
int fnvprime = 0x811C9DC5;
int hash = 0;
for (int i = 0; i < str.length(); i++) {
hash *= fnvprime;
hash ^= (int)str[i];
}
return hash & 0x7FFFFFFF;
}