📜  djb2算法之——C编程语言代码示例

📅  最后修改于: 2022-03-11 15:04:36.349000             🧑  作者: Mango

代码示例1
// Djb2 hash function - really good and implementable code
unsigned long hash(char *str) {

        unsigned long hash = 5381;
        int c;
        while ((c = *str++))
            hash = ((hash << 5) + hash) + c; /* hash * 33 + c */
        return hash % NUM_BUCKETS;

}