StringHasher Struct Reference

A hashing function object for strings. More...

#include <stl-utils.h>

Collaboration diagram for StringHasher:

Public Member Functions

size_t operator() (const std::string &str) const noexcept
 

Static Private Attributes

static const int kPrime = 7853
 

Detailed Description

A hashing function object for strings.

Definition at line 248 of file stl-utils.h.

Member Function Documentation

◆ operator()()

size_t operator() ( const std::string &  str) const
inlinenoexcept

Definition at line 249 of file stl-utils.h.

References VectorHasher< Int >::kPrime.

249  {
250  size_t ans = 0, len = str.length();
251  const char *c = str.c_str(), *end = c + len;
252  for (; c != end; c++) {
253  ans *= kPrime;
254  ans += *c;
255  }
256  return ans;
257  }
static const int kPrime
Definition: stl-utils.h:259

Member Data Documentation

◆ kPrime

const int kPrime = 7853
staticprivate

Definition at line 259 of file stl-utils.h.


The documentation for this struct was generated from the following file: