Skip to content

Instantly share code, notes, and snippets.

@doyonghoon
Created December 3, 2016 03:53
Show Gist options
  • Save doyonghoon/ed2a5774ac478690315a0c3181bfe158 to your computer and use it in GitHub Desktop.
Save doyonghoon/ed2a5774ac478690315a0c3181bfe158 to your computer and use it in GitHub Desktop.
Hashcode Generator
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