32 #ifndef _TAG_HASH_COMPARE_HH_ALREADY_INCLUDED 33 #define _TAG_HASH_COMPARE_HH_ALREADY_INCLUDED 37 #include <cnc/internal/cnc_stddef.h> 39 #include <cnc/internal/tbbcompat.h> 40 #include <tbb/concurrent_hash_map.h> 55 template<
typename T >
71 template<
typename T >
82 size_t operator()(
const T * x )
const 84 return reinterpret_cast< size_t >( x ) * 2654435761;
94 size_t operator()(
const char * x )
const 110 bool operator()(
const char * x,
const char * y )
const 112 return ( strcmp( x, y ) == 0 );
122 size_t operator()(
const std::string & x )
const 126 for( std::string::const_iterator i = x.begin(); i != x.end(); ++ i ) {
137 bool operator()(
const std::string & a,
const std::string & b )
const 139 return ( a.compare( b ) == 0 );
146 template<
class T,
class Allocator >
147 struct cnc_hash< std::vector< T, Allocator > >
150 size_t operator()(
const std::vector< T, Allocator > & x )
const 152 size_t _n = x.size();
153 CNC_ASSERT( _n > 0 );
157 case 1 :
return _hasher.operator()( x[0] );
158 case 2 :
return ( _hasher.operator()( x[0] )
159 + ( _hasher.operator()( x[1] ) << 10 ) );;
160 case 3 :
return ( _hasher.operator()( x[0] )
161 + ( _hasher.operator()( x[1] ) << 9 )
162 + ( _hasher.operator()( x[2] ) << 18 ) );
163 case 4 :
return ( _hasher.operator()( x[0] )
164 + ( _hasher.operator()( x[3] ) << 8 )
165 + ( _hasher.operator()( x[1] ) << 16 )
166 + ( _hasher.operator()( x[2] ) << 24 ) );
169 for(
typename std::vector< T, Allocator >::const_iterator i = x.begin(); i != x.end(); ++ i ) {
170 _n = _n * 3 + _hasher.operator()( *i );
189 size_t hash(
const T & x )
const 194 bool equal(
const T & x,
const T & y )
const 200 #endif // _TAG_HASH_COMPARE_HH_ALREADY_INCLUDED bool equal(const T &x, const T &y) const
Provides hash operators for hashing.
Provides hash and equality operators for hashing as used by item_collections.
Provides equality operators for hashing.
size_t hash(const T &x) const