3 #ifndef GAUDIKERNEL_HASH_H
4 #define GAUDIKERNEL_HASH_H 1
14 #include "boost/functional/hash.hpp"
30 struct GenericHash :
public std::unary_function<T,std::size_t>
36 std::size_t len =
sizeof(T) ;
37 const char* p =
reinterpret_cast<const char*
>( &key );
38 while( len-- ) { res = ( res << 1 ) ^ *p; ++p; }
98 struct Hash :
public std::unary_function<T,std::size_t>
102 inline std::size_t
operator() (
const T& key )
const;
108 struct Hash<T*> :
public std::unary_function<const T*,std::size_t>
112 inline std::size_t operator() (
const T* key )
const;
117 template <
class T,
unsigned N>
118 struct Hash<T(&)[
N]> :
public std::unary_function<T(&)[
N],std::size_t>
122 inline std::size_t operator() ( T (&key) [
N] )
const
123 {
return boost::hash_range ( key , key + N ) ; }
127 template <
class T,
unsigned N>
128 struct Hash<const T(&)[
N]> :
public std::unary_function<
const T(&)[
N],std::size_t>
132 inline std::size_t operator() (
const T (&key) [
N] )
const
133 {
return boost::hash_range ( key , key + N ) ; }
154 using namespace boost ;
161 using namespace boost ;
168 std::size_t seed = 0 ;
169 while ( key ) { boost::hash_combine ( seed , *key ) ; ++key ; }
178 #endif // GAUDIKERNEL_HASH_H
std::size_t hash_value(const Gaudi::StringKey &key)
hash-function: heeded for boost::hash
the partial specialization for pointers
Generic hash implementation (for easy migration to the new Hash class).
std::size_t operator()(const T &key) const
the generic hash function
std::size_t operator()(const T &key) const
the hash-function