Gaudi Framework, version v21r9

Home   Generated: 3 May 2010

GaudiUtils::Hash< T > Class Template Reference

Simple hash function. More...

#include <GaudiKernel/Hash.h>

Inheritance diagram for GaudiUtils::Hash< T >:

Inheritance graph
[legend]
Collaboration diagram for GaudiUtils::Hash< T >:

Collaboration graph
[legend]

List of all members.

Public Member Functions

std::size_t operator() (const T &key) const
 the hash-function
template<>
size_t operator() (const GaudiAlg::ID &key) const
template<>
std::size_t operator() (const char *key) const


Detailed Description

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

Simple hash function.

The default implementation is based on boost::hash

Attention:
There is no generic a'la Stroustrup implementation valid for "any" objects.
See also:
GaudiUtils::GenericHash
Attention:
The hashing of pointers does not rely on hash for objects
The usage *requires* to provide the specialization The default specialization are provided by boost::bash_value for

To provide own specialization for type TYPE or TYPE* there are four ways:

The first and the last ways are recommended. The second way can be needed if e.g. TYPE has non trivial properties, e.g. one need to use non-const or non-ref forms of hashing value For the last way the function must reside in the same namespace, where TYPE is defines, therefore if TYPE is in a global namespace it is better to avoid this way. The most natural place for this function is a "friend function" of the class. In this way it can have access to some useful internals of the class. However this is a bit intrusive way. The third way is not recommended, since sooner or later we'll need to migrate from boost::hash to std::tr1::hash.

Comparing the previous Gaudi implementation of GaudiUtils::Hash and boost::bash specializations, one can expect:

Probably the first two items are compensated by better "hashing"-performance

Author:
Marco Clemencic

Vanya BELYAEV Ivan.Belyaev@nikhef.nl

Date:
2005-10-07

Definition at line 98 of file Hash.h.


Member Function Documentation

template<class T>
std::size_t GaudiUtils::Hash< T >::operator() ( const T &  key  )  const [inline]

the hash-function

the generic implementations of hash-function

Definition at line 152 of file Hash.h.

00153   {
00154     using namespace boost ;
00155     return hash_value ( key ) ;
00156   }

template<>
size_t GaudiUtils::Hash< GaudiAlg::ID >::operator() ( const GaudiAlg::ID key  )  const [inline]

Definition at line 147 of file GaudiHistoID.h.

00147 { return key.hash () ; }   

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

Definition at line 166 of file Hash.h.

00167   {
00168     std::size_t seed = 0 ;
00169     while ( key ) { boost::hash_combine ( seed , *key ) ; ++key ; }
00170     return seed ;
00171   }


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

Generated at Mon May 3 12:29:10 2010 for Gaudi Framework, version v21r9 by Doxygen version 1.5.6 written by Dimitri van Heesch, © 1997-2004