From b2912f52b96b1f0374132529a3d9f0d22f334450 Mon Sep 17 00:00:00 2001 From: khizmax Date: Sun, 6 Sep 2015 09:02:39 +0300 Subject: [PATCH] Added less() predicate for CityHash --- tests/hashing/hash_func.h | 26 +++++++++++++++++++ tests/unit/map2/map_type_multilevel_hashmap.h | 2 ++ 2 files changed, 28 insertions(+) diff --git a/tests/hashing/hash_func.h b/tests/hashing/hash_func.h index 3ea5ce92..cbef26df 100644 --- a/tests/hashing/hash_func.h +++ b/tests/hashing/hash_func.h @@ -61,6 +61,14 @@ namespace hashing { { return CityHash32( reinterpret_cast( &s ), sizeof(s)); } + + struct less + { + bool operator()( hash_type lhs, hash_type rhs ) const + { + return lhs < rhs; + } + }; }; class city64 { @@ -82,6 +90,14 @@ namespace hashing { { return CityHash64( reinterpret_cast( &s ), sizeof(s)); } + + struct less + { + bool operator()( hash_type lhs, hash_type rhs ) const + { + return lhs < rhs; + } + }; }; class city128 { @@ -103,6 +119,16 @@ namespace hashing { { return CityHash128( reinterpret_cast( &s ), sizeof(s)); } + + struct less + { + bool operator()( hash_type const& lhs, hash_type const& rhs ) const + { + if ( lhs.first != rhs.first ) + return lhs.second < rhs.second; + return lhs.first < rhs.second; + } + }; }; } // namespace hashing diff --git a/tests/unit/map2/map_type_multilevel_hashmap.h b/tests/unit/map2/map_type_multilevel_hashmap.h index 307ebc1a..4dc547a1 100644 --- a/tests/unit/map2/map_type_multilevel_hashmap.h +++ b/tests/unit/map2/map_type_multilevel_hashmap.h @@ -82,6 +82,7 @@ namespace map2 { struct traits_MultiLevelHashMap_city64 : public cc::multilevel_hashmap::traits { typedef ::hashing::city64 hash; + typedef ::hashing::city64::less less; }; typedef MultiLevelHashMap< cds::gc::HP, Key, Value, traits_MultiLevelHashMap_city64 > MultiLevelHashMap_hp_city64; typedef MultiLevelHashMap< cds::gc::DHP, Key, Value, traits_MultiLevelHashMap_city64 > MultiLevelHashMap_dhp_city64; @@ -96,6 +97,7 @@ namespace map2 { struct traits_MultiLevelHashMap_city128 : public cc::multilevel_hashmap::traits { typedef ::hashing::city128 hash; + typedef ::hashing::city128::less less; }; typedef MultiLevelHashMap< cds::gc::HP, Key, Value, traits_MultiLevelHashMap_city128 > MultiLevelHashMap_hp_city128; typedef MultiLevelHashMap< cds::gc::DHP, Key, Value, traits_MultiLevelHashMap_city128 > MultiLevelHashMap_dhp_city128; -- 2.34.1