Teuchos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Static Public Member Functions | Static Private Attributes | Related Functions
Teuchos::HashUtils Class Reference

Utilities for generating hashcodes. This is not a true hash ! For all ints and types less than ints it returns the i/p typecasted as an int. For every type more than the size of int it is only slightly more smarter where it adds the bits into int size chunks and calls that an hash. Used with a capacity limited array this will lead to one of the simplest hashes. Ideally this should be deprecated and not used at all. More...

#include <Teuchos_HashUtils.hpp>

List of all members.

Static Public Member Functions

static int nextPrime (int newCapacity)
static int getHashCode (const unsigned char *a, size_t len)

Static Private Attributes

static const int primeCount_ = 33
static const int primes_ []

Related Functions

(Note that these are not member functions.)

template<class T >
int hashCode (const T &x)
 Standard interface for getting the hash code of an object.
template<>
int hashCode (const int &x)
 Get the hash code of an int.
template<>
int hashCode (const double &x)
 Get the hash code of a double.
template<>
int hashCode (const bool &x)
 Get the hash code of a bool.
template<>
int hashCode (const long long &x)
 Get the hash code of a long long.
template<>
int hashCode (const long &x)
 Get the hash code of a long.
template<>
int hashCode (const std::string &x)
 Get the hash code of a std::string.

Detailed Description

Utilities for generating hashcodes. This is not a true hash ! For all ints and types less than ints it returns the i/p typecasted as an int. For every type more than the size of int it is only slightly more smarter where it adds the bits into int size chunks and calls that an hash. Used with a capacity limited array this will lead to one of the simplest hashes. Ideally this should be deprecated and not used at all.

Definition at line 66 of file Teuchos_HashUtils.hpp.


Member Function Documentation

int HashUtils::nextPrime ( int  newCapacity) [static]

Definition at line 57 of file Teuchos_HashUtils.cpp.

int HashUtils::getHashCode ( const unsigned char *  a,
size_t  len 
) [static]

helper to hash values larger than int to an int. This is similar to the version in Zoltan2, not a true hash, but this is an improvement over what was done before which was typecasting everything to ints and returning -ve hash codes which was in turn used to index arrays.

Definition at line 83 of file Teuchos_HashUtils.cpp.


Friends And Related Function Documentation

template<class T >
int hashCode ( const T &  x) [related]

Standard interface for getting the hash code of an object.

int hashCode ( const int &  x) [related]

Get the hash code of an int.

Definition at line 95 of file Teuchos_HashUtils.hpp.

int hashCode ( const double &  x) [related]

Get the hash code of a double.

Definition at line 103 of file Teuchos_HashUtils.hpp.

int hashCode ( const bool &  x) [related]

Get the hash code of a bool.

Definition at line 112 of file Teuchos_HashUtils.hpp.

int hashCode ( const long long &  x) [related]

Get the hash code of a long long.

Definition at line 120 of file Teuchos_HashUtils.hpp.

int hashCode ( const long &  x) [related]

Get the hash code of a long.

Definition at line 129 of file Teuchos_HashUtils.hpp.

int hashCode ( const std::string &  x) [related]

Get the hash code of a std::string.

Definition at line 138 of file Teuchos_HashUtils.hpp.


Member Data Documentation

const int HashUtils::primeCount_ = 33 [static, private]

Definition at line 77 of file Teuchos_HashUtils.hpp.

const int HashUtils::primes_ [static, private]
Initial value:
 {11, 19, 37, 59, 101, 163, 271, 443, 733, 1187, 1907, 3061,
   4919, 7759, 12379, 19543, 30841, 48487, 75989,
   119089, 185971, 290347, 452027, 703657, 1093237,
   1695781, 2627993, 4067599, 6290467, 9718019,
   15000607, 23133937, 35650091}

Definition at line 78 of file Teuchos_HashUtils.hpp.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines