42#ifndef TEUCHOS_HASHUTILS_H
43#define TEUCHOS_HASHUTILS_H
70 static int nextPrime(
int newCapacity);
71 static int getHashCode(
const unsigned char *a,
size_t len);
77 static const int primeCount_;
78 static const int primes_[];
106 reinterpret_cast<const unsigned char *
>(&x),
sizeof(
unsigned));
115 reinterpret_cast<const unsigned char *
>(&x),
sizeof(
double));
129 template <>
inline int hashCode(
const long long& x)
132 reinterpret_cast<const unsigned char *
>(&x),
sizeof(
long long));
141 reinterpret_cast<const unsigned char *
>(&x),
sizeof(
long));
147 template <>
inline int hashCode(
const std::string& x)
152 const char* str = x.c_str();
153 int len =
static_cast<int>(x.length());
154 int step = len/4 + 1;
158 for (
int i=0; i<len/2; i+=step)
160 rtn += base*(int) str[i];
162 rtn += base*(int) str[len-i-1];
171 size_t maxIntBeforeWrap = std::numeric_limits<int>::max();
173 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,...