Skip to content

Instantly share code, notes, and snippets.

@chancez
Created August 4, 2012 23:44
Show Gist options
  • Save chancez/3260636 to your computer and use it in GitHub Desktop.
Save chancez/3260636 to your computer and use it in GitHub Desktop.
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