Skip to content

Instantly share code, notes, and snippets.

@mrahul17
Created December 23, 2015 14:56
Show Gist options
  • Save mrahul17/8cbe4a3f55aca6673e09 to your computer and use it in GitHub Desktop.
Save mrahul17/8cbe4a3f55aca6673e09 to your computer and use it in GitHub Desktop.
// Taken from http://stackoverflow.com/questions/98153/whats-the-best-hashing-algorithm-to-use-on-a-stl-string-when-using-hash-map
unsigned int hash(const char* s, unsigned int seed = 0)
{
unsigned int hash = seed;
while (*s)
{
hash = hash * 101 + *s++;
}
return hash;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment