TPIE

2362a60
tpie::hash< T > Struct Template Reference

Default tabulation-hashing function for integral (size_t-castable) types. More...

#include <tpie/hash.h>

Public Member Functions

size_t operator() (const T &e) const
 Calculate integer hash using tabulation hashing. More...
 

Detailed Description

template<typename T>
struct tpie::hash< T >

Default tabulation-hashing function for integral (size_t-castable) types.

Template Parameters
TType of value to hash.

Definition at line 41 of file hash.h.

Member Function Documentation

template<typename T>
size_t tpie::hash< T >::operator() ( const T &  e) const
inline

Calculate integer hash using tabulation hashing.

Definition at line 48 of file hash.h.

48  {
49  size_t key = e;
50  size_t result = 0;
51  for(size_t i = 0; i < sizeof(size_t); ++i) {
52  // use the least significant byte as key in the matrix
53  result ^= hash_bits::hash_codes[i][key & 0xFF];
54  key >>= 8;
55  }
56 
57  return result;
58  }

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