VectorHasher< Int > Struct Template Reference

A hashing function-object for vectors. More...

#include <stl-utils.h>

Collaboration diagram for VectorHasher< Int >:

Public Member Functions

size_t operator() (const std::vector< Int > &x) const noexcept
 
 VectorHasher ()
 

Static Private Attributes

static const int kPrime = 7853
 

Detailed Description

template<typename Int>
struct kaldi::VectorHasher< Int >

A hashing function-object for vectors.

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

Constructor & Destructor Documentation

◆ VectorHasher()

VectorHasher ( )
inline

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

References KALDI_ASSERT_IS_INTEGER_TYPE.

226  { // Check we're instantiated with an integer type.
228  }
#define KALDI_ASSERT_IS_INTEGER_TYPE(I)
Definition: kaldi-utils.h:133

Member Function Documentation

◆ operator()()

size_t operator() ( const std::vector< Int > &  x) const
inlinenoexcept

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

References VectorHasher< Int >::kPrime.

217  {
218  size_t ans = 0;
219  typename std::vector<Int>::const_iterator iter = x.begin(), end = x.end();
220  for (; iter != end; ++iter) {
221  ans *= kPrime;
222  ans += *iter;
223  }
224  return ans;
225  }
static const int kPrime
Definition: stl-utils.h:230

Member Data Documentation

◆ kPrime

const int kPrime = 7853
staticprivate

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

Referenced by VectorHasher< Int >::operator()(), and StringHasher::operator()().


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