All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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 250 of file stl-utils.h.

Member Function Documentation

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

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

References StringHasher::kPrime.

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

Member Data Documentation

const int kPrime = 7853

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

Referenced by StringHasher::operator()().

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