Created
December 3, 2016 03:53
-
-
Save doyonghoon/ed2a5774ac478690315a0c3181bfe158 to your computer and use it in GitHub Desktop.
Hashcode Generator
This file contains 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
int hashCode(string text) { | |
int hash = 0; | |
size_t strlen = text.length(), i; | |
char character; | |
if (strlen == 0) { | |
return hash; | |
} | |
for (i = 0; i < strlen; i++) { | |
character = text.at(i); | |
hash = (31 * hash) + (character); | |
} | |
return hash; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment