Added less() predicate for CityHash
authorkhizmax <libcds.dev@gmail.com>
Sun, 6 Sep 2015 06:02:39 +0000 (09:02 +0300)
committerkhizmax <libcds.dev@gmail.com>
Sun, 6 Sep 2015 06:02:39 +0000 (09:02 +0300)
tests/hashing/hash_func.h
tests/unit/map2/map_type_multilevel_hashmap.h

index 3ea5ce923e63336500ce99726d8efaa257fba770..cbef26dfac66fdf731d64c7cc57950f98a36814a 100644 (file)
@@ -61,6 +61,14 @@ namespace hashing {
         {
             return CityHash32( reinterpret_cast<char const *>( &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<char const *>( &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<char const *>( &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
index 307ebc1a9b4a433858f1f848761d213fb97d5e2b..4dc547a116b76c0d5baf06fcb602fcad6456ed34 100644 (file)
@@ -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;