| # Gaudi Framework, version v20r3
Generated: 24 Nov 2008

# GaudiUtils::Hash< T > Class Template Reference

`#include <GaudiKernel/Hash.h>`

Inheritance diagram for GaudiUtils::Hash< T >:

[legend]

List of all members.

## Detailed Description

### template<class T>
class GaudiUtils::Hash< T >

Simple hash function based on Stroustrup example.

It provides correct handling of pointers, std::string and char*.

Author:
  Marco Clemencic

Date:
  2005-10-07

Definition at line 21 of file Hash.h.

## Public Types
enum | { bucket_size = 4, min_buckets = 8 }
## Public Member Functions
size_t | operator() (const T &key) const
bool | operator() (const T &key1, const T &key2) const
template<>
size_t | operator() (const int &key) const
template<>
size_t | operator() (const unsigned int &key) const
template<>
size_t | operator() (const long &key) const
template<>
size_t | operator() (const unsigned long &key) const
template<>
size_t | operator() (const long long &key) const
template<>
size_t | operator() (const unsigned long long &key) const
template<>
size_t | operator() (const std::string &key) const
template<>
size_t | operator() (const char *key) const
## Protected Attributes
std::less< T > | comp
| comparison operator needed for VC++

## Member Enumeration Documentation

template<class T>

anonymous enum

Enumerator:

  bucket_size |
  min_buckets |

Definition at line 25 of file Hash.h.

    00025          { // parameters for hash table
    00026       bucket_size = 4,    // 0 < bucket_size
    00027       min_buckets = 8};   // min_buckets = 2 ^^ N, 0 < N

## Member Function Documentation

template<class T>

size_t GaudiUtils::Hash< T >::operator() | ( | const T & | key | ) | const`[inline]`

Definition at line 58 of file Hash.h.

    00058                                                   {
    00059     size_t res = 0 ;
    00060     size_t len = sizeof(T) ;
    00061     const char* p = reinterpret_cast<const char*>( &key );
    00062     while( len-- ) { res = ( res << 1 ) ^ *p; ++p; }
    00063     return res;
    00064   }

template<class T>

bool GaudiUtils::Hash< T >::operator() | ( | const T & | key1,
|  | const T & | key2 |
| ) |  |  | const`[inline]`

Definition at line 29 of file Hash.h.

    00029                                                                   {
    00030       // test if key1 ordered before key2
    00031       return comp(key1,key2);
    00032     }

template<>

size_t GaudiUtils::Hash< int >::operator() | ( | const int & | key | ) | const`[inline]`

Definition at line 67 of file Hash.h.

    00067 { return (size_t)key; }

template<>

size_t GaudiUtils::Hash< unsigned int >::operator() | ( | const unsigned int & | key | ) | const`[inline]`

Definition at line 70 of file Hash.h.

    00070 { return (size_t)key; }

template<>

size_t GaudiUtils::Hash< long >::operator() | ( | const long & | key | ) | const`[inline]`

Definition at line 73 of file Hash.h.

    00073 { return (size_t)key; }

template<>

size_t GaudiUtils::Hash< unsigned long >::operator() | ( | const unsigned long & | key | ) | const`[inline]`

Definition at line 76 of file Hash.h.

    00076 { return (size_t)key; }

template<>

size_t GaudiUtils::Hash< long long >::operator() | ( | const long long & | key | ) | const`[inline]`

Definition at line 79 of file Hash.h.

    00079 { return (size_t)key; }

template<>

size_t GaudiUtils::Hash< unsigned long long >::operator() | ( | const unsigned long long & | key | ) | const`[inline]`

Definition at line 82 of file Hash.h.

    00082 { return (size_t)key; }

template<>

size_t GaudiUtils::Hash< std::string >::operator() | ( | const std::string & | key | ) | const`[inline]`

Definition at line 96 of file Hash.h.

    00096                                                                          {
    00097     size_t res = 0 ;
    00098     std::string::const_iterator e = key.end();
    00099     std::string::const_iterator p = key.begin();
    00100     while( p != e ) { res = ( res << 1 ) ^ *p; ++p; }
    00101     return res;
    00102   }

template<>

size_t GaudiUtils::Hash< char * >::operator() | ( | const char * | key | ) | const`[inline]`

Definition at line 105 of file Hash.h.

    00105                                                                  {
    00106     size_t res = 0 ;
    00107     if ( 0 == key ) { return 0; }
    00108     while ( *key ) { res = ( res << 1 ) ^ *key; ++key; }
    00109     return res;
    00110   }

## Member Data Documentation

template<class T>

std::less<T> GaudiUtils::Hash< T >::comp`[protected]`

comparison operator needed for VC++

Definition at line 35 of file Hash.h.

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

- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v20r3/GaudiKernel/GaudiKernel/Hash.h