Created
August 4, 2012 23:44
-
-
Save chancez/3260636 to your computer and use it in GitHub Desktop.
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 HashTable::calculateIndex(char const * const name) const | |
{ | |
int length = strlen(name); | |
int i; | |
unsigned int sum = int(name[0]); | |
// Start at 1 because the value for the first character was done above. | |
for (i = 1; i < length; i++) | |
{ | |
sum = (sum * 32 + int(name[i])); | |
} | |
return sum % DEFAULT_CAPACITY; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment