10#ifndef TEUCHOS_HASHUTILS_H
11#define TEUCHOS_HASHUTILS_H
38 static int nextPrime(
int newCapacity);
39 static int getHashCode(
const unsigned char *a,
size_t len);
45 static const int primeCount_;
46 static const int primes_[];
71 template <>
inline int hashCode(
const unsigned& x)
74 reinterpret_cast<const unsigned char *
>(&x),
sizeof(
unsigned));
80 template <>
inline int hashCode(
const double& x)
83 reinterpret_cast<const unsigned char *
>(&x),
sizeof(
double));
97 template <>
inline int hashCode(
const long long& x)
100 reinterpret_cast<const unsigned char *
>(&x),
sizeof(
long long));
109 reinterpret_cast<const unsigned char *
>(&x),
sizeof(
long));
115 template <>
inline int hashCode(
const std::string& x)
120 const char* str = x.c_str();
121 int len =
static_cast<int>(x.length());
122 int step = len/4 + 1;
126 for (
int i=0; i<len/2; i+=step)
128 rtn += base*(int) str[i];
130 rtn += base*(int) str[len-i-1];
139 size_t maxIntBeforeWrap = std::numeric_limits<int>::max();
141 rtn += maxIntBeforeWrap;
Teuchos header file which uses auto-configuration information to include necessary C++ headers.
Utilities for generating hashcodes. This is not a true hash ! For all ints and types less than ints i...
int hashCode(const T &x)
Standard interface for getting the hash code of an object.
int hashCode(const std::string &x)
Get the hash code of a std::string.
int hashCode(const double &x)
Get the hash code of a double.
int hashCode(const long &x)
Get the hash code of a long.
static int getHashCode(const unsigned char *a, size_t len)
int hashCode(const long long &x)
Get the hash code of a long long.
int hashCode(const int &x)
Get the hash code of an int.
int hashCode(const unsigned &x)
Get the hash code of an unsigned.
int hashCode(const bool &x)
Get the hash code of a bool.
The Teuchos namespace contains all of the classes, structs and enums used by Teuchos,...