3 #ifndef CDSUNIT_HASH_FUNC_H
4 #define CDSUNIT_HASH_FUNC_H
6 #include <cds/details/defs.h>
8 #if CDS_BUILD_BITS == 64
9 # include <cds_test/city.h>
14 #if CDS_BUILD_BITS == 64
17 typedef uint32_t hash_type;
19 hash_type operator()( void const * pBuf, size_t len )
21 return CityHash32( reinterpret_cast<char const *>( pBuf ), len );
24 hash_type operator()( std::string const& s )
26 return CityHash32( s.c_str(), s.length() );
30 hash_type operator()( T const& s )
32 return CityHash32( reinterpret_cast<char const *>( &s ), sizeof(s));
37 bool operator()( hash_type lhs, hash_type rhs ) const
46 typedef uint64_t hash_type;
48 hash_type operator()( void const * pBuf, size_t len )
50 return CityHash64( reinterpret_cast<char const *>( pBuf ), len );
53 hash_type operator()( std::string const& s )
55 return CityHash64( s.c_str(), s.length() );
59 hash_type operator()( T const& s )
61 return CityHash64( reinterpret_cast<char const *>( &s ), sizeof(s));
66 bool operator()( hash_type lhs, hash_type rhs ) const
75 typedef uint128 hash_type;
77 hash_type operator()( void const * pBuf, size_t len )
79 return CityHash128( reinterpret_cast<char const *>( pBuf ), len );
82 hash_type operator()( std::string const& s )
84 return CityHash128( s.c_str(), s.length() );
88 hash_type operator()( T const& s )
90 return CityHash128( reinterpret_cast<char const *>( &s ), sizeof(s));
95 bool operator()( hash_type const& lhs, hash_type const& rhs ) const
97 if ( lhs.first != rhs.first )
98 return lhs.second < rhs.second;
99 return lhs.first < rhs.first;
103 #endif // #if CDS_BUILD_BITS == 64
106 } // namespace cds_test
108 #endif // #ifndef CDSUNIT_HASH_FUNC_H