我不是很了解C语言,但是我可以尝试给出一个哈希算法的实现: unsigned int hash(char *str) { unsigned int hash = 5381; int c;
while (c = *str++)
hash = ((hash << 5) + hash) + c; /* hash * 33 + c */
return hash;
}
我不是很了解C语言,但是我可以尝试给出一个哈希算法的实现: unsigned int hash(char *str) { unsigned int hash = 5381; int c;
while (c = *str++)
hash = ((hash << 5) + hash) + c; /* hash * 33 + c */
return hash;
}