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;
18 typedef hash_type result_type;
20 hash_type operator()( void const * pBuf, size_t len ) const
22 return CityHash32( reinterpret_cast<char const *>( pBuf ), len );
25 hash_type operator()( std::string const& s ) const
27 return CityHash32( s.c_str(), s.length() );
31 hash_type operator()( T const& s ) const
33 return CityHash32( reinterpret_cast<char const *>( &s ), sizeof(s));
38 bool operator()( hash_type lhs, hash_type rhs ) const
47 typedef uint64_t hash_type;
48 typedef hash_type result_type;
50 hash_type operator()( void const * pBuf, size_t len ) const
52 return CityHash64( reinterpret_cast<char const *>( pBuf ), len );
55 hash_type operator()( std::string const& s ) const
57 return CityHash64( s.c_str(), s.length() );
61 hash_type operator()( T const& s ) const
63 return CityHash64( reinterpret_cast<char const *>( &s ), sizeof(s));
68 bool operator()( hash_type lhs, hash_type rhs ) const
77 typedef uint128 hash_type;
78 typedef hash_type result_type;
80 hash_type operator()( void const * pBuf, size_t len ) const
82 return CityHash128( reinterpret_cast<char const *>( pBuf ), len );
85 hash_type operator()( std::string const& s ) const
87 return CityHash128( s.c_str(), s.length() );
91 hash_type operator()( T const& s ) const
93 return CityHash128( reinterpret_cast<char const *>( &s ), sizeof(s));
98 bool operator()( hash_type const& lhs, hash_type const& rhs ) const
100 if ( lhs.first != rhs.first )
101 return lhs.second < rhs.second;
102 return lhs.first < rhs.first;
106 #endif // #if CDS_BUILD_BITS == 64
109 } // namespace cds_test
111 #endif // #ifndef CDSUNIT_HASH_FUNC_H