字符串hash-BKDRHash

 1 unsigned int BKDRHash(char *str)

 2 {

 3     unsigned int seed = 131; // 31 131 1313 13131 131313 etc..

 4     unsigned int hash = 0;

 5 

 6     while (*str)

 7     {

 8         hash = hash * seed + (*str++);

 9     }

10 

11     return (hash & 0x7FFFFFFF);

12 }
View Code

 

你可能感兴趣的:(hash)