Fixed: set_DelOdd and map_DelOdd tests for FeldmanHashSet/Map now use correct compare...
[libcds.git] / test / stress / set / set_type_feldman_hashset.h
index 03c06869d01cefe6376b573f6ec3466e543b9b53..a0e3527cc7d8b8cf4890a3f2be861474ee3f6fd8 100644 (file)
@@ -5,7 +5,7 @@
 
     Source code repo: http://github.com/khizmax/libcds/
     Download: http://sourceforge.net/projects/libcds/files/
 
     Source code repo: http://github.com/khizmax/libcds/
     Download: http://sourceforge.net/projects/libcds/files/
-    
+
     Redistribution and use in source and binary forms, with or without
     modification, are permitted provided that the following conditions are met:
 
     Redistribution and use in source and binary forms, with or without
     modification, are permitted provided that the following conditions are met:
 
@@ -25,7 +25,7 @@
     SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
     CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
     OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
     CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
     OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.     
+    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
 #ifndef CDSUNIT_SET_TYPE_FELDMAN_HASHSET_H
 */
 
 #ifndef CDSUNIT_SET_TYPE_FELDMAN_HASHSET_H
@@ -63,6 +63,11 @@ namespace set {
         typedef typename T::hasher hasher;
         typedef typename get_extracted_ptr<GC>::extracted_ptr extracted_ptr;
 
         typedef typename T::hasher hasher;
         typedef typename get_extracted_ptr<GC>::extracted_ptr extracted_ptr;
 
+        template <typename OtherTraits>
+        struct rebind_traits {
+            typedef FeldmanHashSet<GC, T, OtherTraits > result;
+        };
+
         template <class Config>
         FeldmanHashSet( Config const& cfg )
             : base_class( cfg.s_nFeldmanSet_HeadBits, cfg.s_nFeldmanSet_ArrayBits )
         template <class Config>
         FeldmanHashSet( Config const& cfg )
             : base_class( cfg.s_nFeldmanSet_HeadBits, cfg.s_nFeldmanSet_ArrayBits )
@@ -83,13 +88,13 @@ namespace set {
         template <typename Q>
         extracted_ptr extract(Q const& key)
         {
         template <typename Q>
         extracted_ptr extract(Q const& key)
         {
-            return base_class::extract( hasher()(key) );
+            return base_class::extract( hasher()(key));
         }
 
         template <typename Q>
         bool contains( Q const& key )
         {
         }
 
         template <typename Q>
         bool contains( Q const& key )
         {
-            return base_class::contains( hasher()(key) );
+            return base_class::contains( hasher()(key));
         }
 
         // for testing
         }
 
         // for testing
@@ -133,11 +138,11 @@ namespace set {
 
             hash_type hash;
 
 
             hash_type hash;
 
-            /*explicit*/ key_val( key_type const& k ): base(k), hash( hasher()( k )) {}
+            explicit key_val( key_type const& k ): base(k), hash( hasher()( k )) {}
             key_val( key_type const& k, value_type const& v ): base(k, v), hash( hasher()( k )) {}
 
             template <typename K>
             key_val( key_type const& k, value_type const& v ): base(k, v), hash( hasher()( k )) {}
 
             template <typename K>
-            /*explicit*/ key_val( K const& k ): base(k), hash( hasher()( k )) {}
+            explicit key_val( K const& k ): base(k), hash( hasher()( k )) {}
 
             template <typename K, typename T>
             key_val( K const& k, T const& v ): base(k, v), hash( hasher()( k )) {}
 
             template <typename K, typename T>
             key_val( K const& k, T const& v ): base(k, v), hash( hasher()( k )) {}
@@ -251,11 +256,11 @@ namespace set {
             {
                 typedef typename set_type_base< Key, Val >::key_val base_class;
 
             {
                 typedef typename set_type_base< Key, Val >::key_val base_class;
 
-                /*explicit*/ key_val(key_type const& k) : base_class(k) {}
+                explicit key_val(key_type const& k) : base_class(k) {}
                 key_val(key_type const& k, value_type const& v) : base_class(k, v) {}
 
                 template <typename K>
                 key_val(key_type const& k, value_type const& v) : base_class(k, v) {}
 
                 template <typename K>
-                /*explicit*/ key_val(K const& k) : base_class(k) {}
+                explicit key_val(K const& k) : base_class(k) {}
 
                 template <typename K, typename T>
                 key_val(K const& k, T const& v) : base_class(k, v) {}
 
                 template <typename K, typename T>
                 key_val(K const& k, T const& v) : base_class(k, v) {}
@@ -267,17 +272,34 @@ namespace set {
                     {
                         return key_type( k );
                     }
                     {
                         return key_type( k );
                     }
+
+                    key_type const& operator()( key_val const& kv ) const
+                    {
+                        return kv.key;
+                    }
+
+                    key_type const& operator()( key_type const& k ) const
+                    {
+                        return k;
+                    }
                 };
             };
 
             struct traits : public cc::feldman_hashset::traits
             {
                 struct hash_accessor {
                 };
             };
 
             struct traits : public cc::feldman_hashset::traits
             {
                 struct hash_accessor {
-                    key_type operator()(key_val const& kv)
+                    key_type const& operator()( key_val const& kv ) const
                     {
                         return kv.key;
                     }
                     {
                         return kv.key;
                     }
+
+                    key_type const& operator()( key_type const& k ) const
+                    {
+                        return k;
+                    }
                 };
                 };
+
+                typedef set::cmp<Key>   compare;
             };
 
             struct traits_stat : public traits
             };
 
             struct traits_stat : public traits
@@ -314,7 +336,8 @@ namespace set {
         std::vector< cds::intrusive::feldman_hashset::level_statistics > level_stat;
         s.get_level_statistics( level_stat );
 
         std::vector< cds::intrusive::feldman_hashset::level_statistics > level_stat;
         s.get_level_statistics( level_stat );
 
-        o << s.statistics() << level_stat;
+        o << s.statistics()
+          << level_stat;
     }
 } // namespace set
 
     }
 } // namespace set
 
@@ -326,17 +349,40 @@ namespace set {
     }
 
 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
     }
 
 #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
-#   define CDSSTRESS_FeldmanHashSet_SHRCU( fixture, test_case, key_type, value_type ) \
+#   define CDSSTRESS_FeldmanHashSet_fixed_SHRCU( fixture, test_case, key_type, value_type ) \
         CDSSTRESS_FeldmanHashSet_case( fixture, test_case, FeldmanHashSet_rcu_shb_fixed,      key_type, value_type ) \
         CDSSTRESS_FeldmanHashSet_case( fixture, test_case, FeldmanHashSet_rcu_sht_fixed,      key_type, value_type ) \
         CDSSTRESS_FeldmanHashSet_case( fixture, test_case, FeldmanHashSet_rcu_shb_fixed_stat, key_type, value_type ) \
         CDSSTRESS_FeldmanHashSet_case( fixture, test_case, FeldmanHashSet_rcu_sht_fixed_stat, key_type, value_type )
         CDSSTRESS_FeldmanHashSet_case( fixture, test_case, FeldmanHashSet_rcu_shb_fixed,      key_type, value_type ) \
         CDSSTRESS_FeldmanHashSet_case( fixture, test_case, FeldmanHashSet_rcu_sht_fixed,      key_type, value_type ) \
         CDSSTRESS_FeldmanHashSet_case( fixture, test_case, FeldmanHashSet_rcu_shb_fixed_stat, key_type, value_type ) \
         CDSSTRESS_FeldmanHashSet_case( fixture, test_case, FeldmanHashSet_rcu_sht_fixed_stat, key_type, value_type )
+
+#   define CDSSTRESS_FeldmanHashSet_stdhash_SHRCU( fixture, test_case, key_type, value_type ) \
+        CDSSTRESS_FeldmanHashSet_case( fixture, test_case, FeldmanHashSet_rcu_shb_stdhash,      key_type, value_type ) \
+        CDSSTRESS_FeldmanHashSet_case( fixture, test_case, FeldmanHashSet_rcu_sht_stdhash,      key_type, value_type ) \
+        CDSSTRESS_FeldmanHashSet_case( fixture, test_case, FeldmanHashSet_rcu_shb_stdhash_stat, key_type, value_type ) \
+        CDSSTRESS_FeldmanHashSet_case( fixture, test_case, FeldmanHashSet_rcu_sht_stdhash_stat, key_type, value_type )
+
+#   if CDS_BUILD_BITS == 64
+#       define CDSSTRESS_FeldmanHashSet_city_SHRCU( fixture, test_case, key_type, value_type ) \
+            CDSSTRESS_FeldmanHashSet_case( fixture, test_case, FeldmanHashSet_rcu_shb_city64,       key_type, value_type ) \
+            CDSSTRESS_FeldmanHashSet_case( fixture, test_case, FeldmanHashSet_rcu_sht_city64,       key_type, value_type ) \
+            CDSSTRESS_FeldmanHashSet_case( fixture, test_case, FeldmanHashSet_rcu_shb_city64_stat,  key_type, value_type ) \
+            CDSSTRESS_FeldmanHashSet_case( fixture, test_case, FeldmanHashSet_rcu_sht_city64_stat,  key_type, value_type ) \
+            CDSSTRESS_FeldmanHashSet_case( fixture, test_case, FeldmanHashSet_rcu_shb_city128,      key_type, value_type ) \
+            CDSSTRESS_FeldmanHashSet_case( fixture, test_case, FeldmanHashSet_rcu_sht_city128,      key_type, value_type ) \
+            CDSSTRESS_FeldmanHashSet_case( fixture, test_case, FeldmanHashSet_rcu_shb_city128_stat, key_type, value_type ) \
+            CDSSTRESS_FeldmanHashSet_case( fixture, test_case, FeldmanHashSet_rcu_sht_city128_stat, key_type, value_type )
+#   else
+#       define CDSSTRESS_FeldmanHashSet_city_SHRCU( fixture, test_case, key_type, value_type )
+#   endif
+
 #else
 #else
-#   define CDSSTRESS_FeldmanHashSet_SHRCU( fixture, test_case, key_type, value_type )
+#   define CDSSTRESS_FeldmanHashSet_fixed_SHRCU( fixture, test_case, key_type, value_type )
+#   define CDSSTRESS_FeldmanHashSet_stdhash_SHRCU( fixture, test_case, key_type, value_type )
+#   define CDSSTRESS_FeldmanHashSet_city_SHRCU( fixture, test_case, key_type, value_type )
 #endif
 
 
 #endif
 
 
-#define CDSSTRESS_FeldmanHashSet( fixture, test_case, key_type, value_type ) \
+#define CDSSTRESS_FeldmanHashSet_fixed( fixture, test_case, key_type, value_type ) \
     CDSSTRESS_FeldmanHashSet_case( fixture, test_case, FeldmanHashSet_hp_fixed,             key_type, value_type ) \
     CDSSTRESS_FeldmanHashSet_case( fixture, test_case, FeldmanHashSet_dhp_fixed,            key_type, value_type ) \
     CDSSTRESS_FeldmanHashSet_case( fixture, test_case, FeldmanHashSet_rcu_gpi_fixed,        key_type, value_type ) \
     CDSSTRESS_FeldmanHashSet_case( fixture, test_case, FeldmanHashSet_hp_fixed,             key_type, value_type ) \
     CDSSTRESS_FeldmanHashSet_case( fixture, test_case, FeldmanHashSet_dhp_fixed,            key_type, value_type ) \
     CDSSTRESS_FeldmanHashSet_case( fixture, test_case, FeldmanHashSet_rcu_gpi_fixed,        key_type, value_type ) \
@@ -347,6 +393,62 @@ namespace set {
     CDSSTRESS_FeldmanHashSet_case( fixture, test_case, FeldmanHashSet_rcu_gpi_fixed_stat,   key_type, value_type ) \
     CDSSTRESS_FeldmanHashSet_case( fixture, test_case, FeldmanHashSet_rcu_gpb_fixed_stat,   key_type, value_type ) \
     CDSSTRESS_FeldmanHashSet_case( fixture, test_case, FeldmanHashSet_rcu_gpt_fixed_stat,   key_type, value_type ) \
     CDSSTRESS_FeldmanHashSet_case( fixture, test_case, FeldmanHashSet_rcu_gpi_fixed_stat,   key_type, value_type ) \
     CDSSTRESS_FeldmanHashSet_case( fixture, test_case, FeldmanHashSet_rcu_gpb_fixed_stat,   key_type, value_type ) \
     CDSSTRESS_FeldmanHashSet_case( fixture, test_case, FeldmanHashSet_rcu_gpt_fixed_stat,   key_type, value_type ) \
-    CDSSTRESS_FeldmanHashSet_SHRCU( fixture, test_case, key_type, value_type )
+    CDSSTRESS_FeldmanHashSet_fixed_SHRCU( fixture, test_case, key_type, value_type )
+
+#define CDSSTRESS_FeldmanHashSet_stdhash_rcu_gpi( fixture, test_case, key_type, value_type ) \
+    CDSSTRESS_FeldmanHashSet_case( fixture, test_case, FeldmanHashSet_rcu_gpi_stdhash,      key_type, value_type ) \
+    CDSSTRESS_FeldmanHashSet_case( fixture, test_case, FeldmanHashSet_rcu_gpi_stdhash_stat, key_type, value_type ) \
+
+#define CDSSTRESS_FeldmanHashSet_stdhash_quick( fixture, test_case, key_type, value_type ) \
+    CDSSTRESS_FeldmanHashSet_case( fixture, test_case, FeldmanHashSet_hp_stdhash,           key_type, value_type ) \
+    CDSSTRESS_FeldmanHashSet_case( fixture, test_case, FeldmanHashSet_dhp_stdhash,          key_type, value_type ) \
+    CDSSTRESS_FeldmanHashSet_case( fixture, test_case, FeldmanHashSet_rcu_gpb_stdhash,      key_type, value_type ) \
+    CDSSTRESS_FeldmanHashSet_case( fixture, test_case, FeldmanHashSet_rcu_gpt_stdhash,      key_type, value_type ) \
+    CDSSTRESS_FeldmanHashSet_case( fixture, test_case, FeldmanHashSet_hp_stdhash_stat,      key_type, value_type ) \
+    CDSSTRESS_FeldmanHashSet_case( fixture, test_case, FeldmanHashSet_dhp_stdhash_stat,     key_type, value_type ) \
+    CDSSTRESS_FeldmanHashSet_case( fixture, test_case, FeldmanHashSet_rcu_gpb_stdhash_stat, key_type, value_type ) \
+    CDSSTRESS_FeldmanHashSet_case( fixture, test_case, FeldmanHashSet_rcu_gpt_stdhash_stat, key_type, value_type ) \
+    CDSSTRESS_FeldmanHashSet_stdhash_SHRCU( fixture, test_case, key_type, value_type )
+
+#define CDSSTRESS_FeldmanHashSet_stdhash( fixture, test_case, key_type, value_type ) \
+    CDSSTRESS_FeldmanHashSet_stdhash_quick( fixture, test_case, key_type, value_type ) \
+    CDSSTRESS_FeldmanHashSet_stdhash_rcu_gpi( fixture, test_case, key_type, value_type ) \
+
+#if CDS_BUILD_BITS == 64
+#   define CDSSTRESS_FeldmanHashSet_city_rcu_gpi( fixture, test_case, key_type, value_type ) \
+        CDSSTRESS_FeldmanHashSet_case( fixture, test_case, FeldmanHashSet_rcu_gpi_city64,       key_type, value_type ) \
+        CDSSTRESS_FeldmanHashSet_case( fixture, test_case, FeldmanHashSet_rcu_gpi_city64_stat,  key_type, value_type ) \
+        CDSSTRESS_FeldmanHashSet_case( fixture, test_case, FeldmanHashSet_rcu_gpi_city128,      key_type, value_type ) \
+        CDSSTRESS_FeldmanHashSet_case( fixture, test_case, FeldmanHashSet_rcu_gpi_city128_stat, key_type, value_type ) \
+
+#   define CDSSTRESS_FeldmanHashSet_city_quick( fixture, test_case, key_type, value_type ) \
+        CDSSTRESS_FeldmanHashSet_case( fixture, test_case, FeldmanHashSet_hp_city64,            key_type, value_type ) \
+        CDSSTRESS_FeldmanHashSet_case( fixture, test_case, FeldmanHashSet_dhp_city64,           key_type, value_type ) \
+        CDSSTRESS_FeldmanHashSet_case( fixture, test_case, FeldmanHashSet_rcu_gpb_city64,       key_type, value_type ) \
+        CDSSTRESS_FeldmanHashSet_case( fixture, test_case, FeldmanHashSet_rcu_gpt_city64,       key_type, value_type ) \
+        CDSSTRESS_FeldmanHashSet_case( fixture, test_case, FeldmanHashSet_hp_city64_stat,       key_type, value_type ) \
+        CDSSTRESS_FeldmanHashSet_case( fixture, test_case, FeldmanHashSet_dhp_city64_stat,      key_type, value_type ) \
+        CDSSTRESS_FeldmanHashSet_case( fixture, test_case, FeldmanHashSet_rcu_gpb_city64_stat,  key_type, value_type ) \
+        CDSSTRESS_FeldmanHashSet_case( fixture, test_case, FeldmanHashSet_rcu_gpt_city64_stat,  key_type, value_type ) \
+        CDSSTRESS_FeldmanHashSet_case( fixture, test_case, FeldmanHashSet_hp_city128,           key_type, value_type ) \
+        CDSSTRESS_FeldmanHashSet_case( fixture, test_case, FeldmanHashSet_dhp_city128,          key_type, value_type ) \
+        CDSSTRESS_FeldmanHashSet_case( fixture, test_case, FeldmanHashSet_rcu_gpb_city128,      key_type, value_type ) \
+        CDSSTRESS_FeldmanHashSet_case( fixture, test_case, FeldmanHashSet_rcu_gpt_city128,      key_type, value_type ) \
+        CDSSTRESS_FeldmanHashSet_case( fixture, test_case, FeldmanHashSet_hp_city128_stat,      key_type, value_type ) \
+        CDSSTRESS_FeldmanHashSet_case( fixture, test_case, FeldmanHashSet_dhp_city128_stat,     key_type, value_type ) \
+        CDSSTRESS_FeldmanHashSet_case( fixture, test_case, FeldmanHashSet_rcu_gpb_city128_stat, key_type, value_type ) \
+        CDSSTRESS_FeldmanHashSet_case( fixture, test_case, FeldmanHashSet_rcu_gpt_city128_stat, key_type, value_type ) \
+        CDSSTRESS_FeldmanHashSet_city_SHRCU( fixture, test_case, key_type, value_type )
+
+#   define CDSSTRESS_FeldmanHashSet_city( fixture, test_case, key_type, value_type ) \
+        CDSSTRESS_FeldmanHashSet_city_quick( fixture, test_case, key_type, value_type ) \
+        CDSSTRESS_FeldmanHashSet_city_rcu_gpi( fixture, test_case, key_type, value_type ) \
+
+
+#else
+#   define CDSSTRESS_FeldmanHashSet_city_rcu_gpi( fixture, test_case, key_type, value_type )
+#   define CDSSTRESS_FeldmanHashSet_city_quick( fixture, test_case, key_type, value_type )
+#   define CDSSTRESS_FeldmanHashSet_city( fixture, test_case, key_type, value_type )
+#endif
 
 #endif // #ifndef CDSUNIT_SET_TYPE_FELDMAN_HASHSET_H
 
 #endif // #ifndef CDSUNIT_SET_TYPE_FELDMAN_HASHSET_H