src/config/config.cc
/*
 * Hashes the given string.
 *
 * Assumes the given string is non-null.
 */
Hashes the given string.
Assumes the given string is non-null.
Hashes the given string . Assumes the given string is non - null .
size_t Config::Hash(const char *string) {
  const size_t prime_start = 31U;
  size_t hash = 3U;
  size_t i = 0;
  while (string[i] != '\0') {
    hash = hash * prime_start + string[i];
    i++;
  }
  return hash % DICT_SIZE;
}
size_t Config :: Hash ( const char * string ) { const size_t prime_start = 31U ; size_t hash = 3U ; size_t i = 0 ; while ( string [ i ] != ' \0 ' ) { hash = hash * prime_start + string [ i ] ; i ++ ; } return hash % DICT_SIZE ; }
Hashes the given string.
Hashes the given string .
// Start with prime numbers for a better distrobution. // Use the prime numbers and the values of the characters in the string // to create a hash for the string.