Last active
July 9, 2019 01:34
-
-
Save kiinlam/7300804b1de908d24574635a9a1d0331 to your computer and use it in GitHub Desktop.
哈希函数,Daniel J.Bernstein 教授发明的,是目前公布的最有效的哈希函数
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public long DJBHash(String str) | |
{ | |
long hash = 5381; | |
for(int i = 0; i < str.length(); i++) | |
{ | |
hash = ((hash << 5) + hash) + str.charAt(i); | |
} | |
return hash; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment