Added MichaelMap<HP> based on IterableList
authorkhizmax <libcds.dev@gmail.com>
Sun, 21 Aug 2016 15:39:52 +0000 (18:39 +0300)
committerkhizmax <libcds.dev@gmail.com>
Sun, 21 Aug 2016 15:39:52 +0000 (18:39 +0300)
19 files changed:
cds/container/details/iterable_list_base.h
cds/container/impl/iterable_kvlist.h
cds/container/impl/lazy_kvlist.h
cds/container/impl/michael_kvlist.h
cds/container/michael_map.h
cds/container/michael_set.h
projects/Win/vc14/gtest-map.vcxproj
projects/Win/vc14/gtest-map.vcxproj.filters
test/unit/map/CMakeLists.txt
test/unit/map/michael_iterable_dhp.cpp [new file with mode: 0644]
test/unit/map/michael_iterable_hp.cpp [new file with mode: 0644]
test/unit/map/michael_lazy_dhp.cpp
test/unit/map/michael_lazy_hp.cpp
test/unit/map/michael_michael_dhp.cpp
test/unit/map/michael_michael_hp.cpp
test/unit/map/test_map.h
test/unit/map/test_map_hp.h
test/unit/map/test_michael_iterable.h [new file with mode: 0644]
test/unit/map/test_michael_iterable_hp.h [new file with mode: 0644]

index 2d6e9fb534decb633fa7d46f0e45125dfc145b28..4dab48ebe0bcafc32d289727cdd28ad5a6cc3472 100644 (file)
@@ -174,8 +174,8 @@ namespace cds { namespace container {
         };
     };
 
         };
     };
 
-    template <typename GC, typename T, typename Traits>
-    struct is_iterable_list< IterableKVList<GC, T, Traits >>
+    template <typename GC, typename K, typename V, typename Traits>
+    struct is_iterable_list< IterableKVList<GC, K, V, Traits >>
     {
         enum {
             value = true
     {
         enum {
             value = true
index 92ec7728541cc121c9537b784ecaf5fc8be7275d..e0a1308bd6f5653485e4d265aa69a3fbb7aab257 100644 (file)
@@ -131,7 +131,7 @@ namespace cds { namespace container {
         typedef typename maker::mapped_type mapped_type;
         typedef typename maker::value_type  value_type;
 #endif
         typedef typename maker::mapped_type mapped_type;
         typedef typename maker::value_type  value_type;
 #endif
-
+        typedef Traits traits;  ///< List traits
         typedef typename base_class::gc           gc;             ///< Garbage collector used
         typedef typename base_class::back_off     back_off;       ///< Back-off strategy used
         typedef typename maker::data_allocator_type allocator_type; ///< Allocator type used for allocate/deallocate data
         typedef typename base_class::gc           gc;             ///< Garbage collector used
         typedef typename base_class::back_off     back_off;       ///< Back-off strategy used
         typedef typename maker::data_allocator_type allocator_type; ///< Allocator type used for allocate/deallocate data
@@ -145,6 +145,22 @@ namespace cds { namespace container {
         /// Guarded pointer
         typedef typename base_class::guarded_ptr guarded_ptr;
 
         /// Guarded pointer
         typedef typename base_class::guarded_ptr guarded_ptr;
 
+        //@cond
+        // Rebind traits (split-list support)
+        template <typename... Options>
+        struct rebind_traits {
+            typedef IterableKVList<
+                gc
+                , key_type, mapped_type
+                , typename cds::opt::make_options< traits, Options...>::type
+            > type;
+        };
+
+        // Stat selector
+        template <typename Stat>
+        using select_stat_wrapper = typename base_class::template select_stat_wrapper< Stat >;
+        //@endcond
+
     protected:
         //@cond
         typedef typename base_class::head_type     head_type;
     protected:
         //@cond
         typedef typename base_class::head_type     head_type;
@@ -326,7 +342,7 @@ namespace cds { namespace container {
             The functor may change non-key fields of \p val; however, \p func must guarantee
             that during changing no any other modifications could be made on this item by concurrent threads.
 
             The functor may change non-key fields of \p val; however, \p func must guarantee
             that during changing no any other modifications could be made on this item by concurrent threads.
 
-            Returns <tt> std::pair<bool, bool> </tt> where \p first is true if operation is successful,
+            @return <tt> std::pair<bool, bool> </tt> where \p first is true if operation is successful,
             \p second is true if new item has been added or \p false if the item with such \p key
             already exists.
 
             \p second is true if new item has been added or \p false if the item with such \p key
             already exists.
 
@@ -650,21 +666,21 @@ namespace cds { namespace container {
         // Split-list support
 
         template <typename K>
         // Split-list support
 
         template <typename K>
-        bool insert_at( head_type& refHead, K const& key )
+        bool insert_at( head_type& refHead, K&& key )
         {
         {
-            return base_class::insert_at( refHead, value_type( key_type( key ), mapped_type() ));
+            return base_class::insert_at( refHead, value_type( key_type( std::forward<K>( key )), mapped_type() ));
         }
 
         template <typename K, typename V>
         }
 
         template <typename K, typename V>
-        bool insert_at( head_type& refHead, const K& key, V const& val )
+        bool insert_at( head_type& refHead, K&& key, V&& val )
         {
         {
-            return base_class::insert_at( refHead, value_type( key_type( key ), val ));
+            return base_class::insert_at( refHead, value_type( key_type( std::forward<K>( key )), std::forward<V>( val )));
         }
 
         template <typename K, typename Func>
         }
 
         template <typename K, typename Func>
-        bool insert_with_at( head_type& refHead, K const& key, Func f )
+        bool insert_with_at( head_type& refHead, K&& key, Func f )
         {
         {
-            return base_class::insert_at( refHead, value_type( key_type( key ), mapped_type()), f );
+            return base_class::insert_at( refHead, value_type( key_type( std::forward<K>( key )), mapped_type()), f );
         }
 
         template <typename K, typename... Args>
         }
 
         template <typename K, typename... Args>
@@ -674,9 +690,9 @@ namespace cds { namespace container {
         }
 
         template <typename K, typename Func>
         }
 
         template <typename K, typename Func>
-        std::pair<bool, bool> update_at( head_type& refHead, const K& key, Func f, bool bAllowInsert )
+        std::pair<bool, bool> update_at( head_type& refHead, K&& key, Func f, bool bAllowInsert )
         {
         {
-            return base_class::update_at( refHead, value_type( key_type( key ), mapped_type()), f, bAllowInsert );
+            return base_class::update_at( refHead, value_type( key_type( std::forward<K>( key )), mapped_type()), f, bAllowInsert );
         }
 
         template <typename K, typename Compare>
         }
 
         template <typename K, typename Compare>
index 5b6599c391cb42290b3910eb4a447bbf40639996..2dad6532ba66b2b8fa28c0b9792f9e3a91d699d0 100644 (file)
@@ -118,7 +118,8 @@ namespace cds { namespace container {
         //@endcond
 
     public:
         //@endcond
 
     public:
-        typedef GC gc; ///< Garbage collector
+        typedef GC     gc;     ///< Garbage collector
+        typedef Traits traits; ///< Traits
 #ifdef CDS_DOXYGEN_INVOKED
         typedef Key                                 key_type        ;   ///< Key type
         typedef Value                               mapped_type     ;   ///< Type of value stored in the list
 #ifdef CDS_DOXYGEN_INVOKED
         typedef Key                                 key_type        ;   ///< Key type
         typedef Value                               mapped_type     ;   ///< Type of value stored in the list
@@ -137,6 +138,22 @@ namespace cds { namespace container {
 
         static CDS_CONSTEXPR const size_t c_nHazardPtrCount = base_class::c_nHazardPtrCount; ///< Count of hazard pointer required for the algorithm
 
 
         static CDS_CONSTEXPR const size_t c_nHazardPtrCount = base_class::c_nHazardPtrCount; ///< Count of hazard pointer required for the algorithm
 
+        //@cond
+        // Rebind traits (split-list support)
+        template <typename... Options>
+        struct rebind_traits {
+            typedef LazyKVList<
+                gc
+                , key_type, mapped_type
+                , typename cds::opt::make_options< traits, Options...>::type
+            > type;
+        };
+
+        // Stat selector
+        template <typename Stat>
+        using select_stat_wrapper = typename base_class::template select_stat_wrapper< Stat >;
+        //@endcond
+
     protected:
         //@cond
         typedef typename base_class::value_type   node_type;
     protected:
         //@cond
         typedef typename base_class::value_type   node_type;
@@ -397,9 +414,9 @@ namespace cds { namespace container {
             Returns \p true if inserting successful, \p false otherwise.
         */
         template <typename K>
             Returns \p true if inserting successful, \p false otherwise.
         */
         template <typename K>
-        bool insert( const K& key )
+        bool insert( K&& key )
         {
         {
-            return insert_at( head(), key );
+            return insert_at( head(), std::forward<K>( key ));
         }
 
         /// Inserts new node with a key and a value
         }
 
         /// Inserts new node with a key and a value
@@ -413,12 +430,12 @@ namespace cds { namespace container {
             Returns \p true if inserting successful, \p false otherwise.
         */
         template <typename K, typename V>
             Returns \p true if inserting successful, \p false otherwise.
         */
         template <typename K, typename V>
-        bool insert( const K& key, const V& val )
+        bool insert( K&& key, V&& val )
         {
             // We cannot use insert with functor here
             // because we cannot lock inserted node for updating
             // Therefore, we use separate function
         {
             // We cannot use insert with functor here
             // because we cannot lock inserted node for updating
             // Therefore, we use separate function
-            return insert_at( head(), key, val );
+            return insert_at( head(), std::forward<K>( key ), std::forward<V>( val ));
         }
 
         /// Inserts new node and initializes it by a functor
         }
 
         /// Inserts new node and initializes it by a functor
@@ -446,9 +463,9 @@ namespace cds { namespace container {
             it is preferable that the initialization should be completed only if inserting is successful.
         */
         template <typename K, typename Func>
             it is preferable that the initialization should be completed only if inserting is successful.
         */
         template <typename K, typename Func>
-        bool insert_with( const K& key, Func func )
+        bool insert_with( K&& key, Func func )
         {
         {
-            return insert_with_at( head(), key, func );
+            return insert_with_at( head(), std::forward<K>( key ), func );
         }
 
         /// Inserts data of type \ref mapped_type constructed with <tt>std::forward<Args>(args)...</tt>
         }
 
         /// Inserts data of type \ref mapped_type constructed with <tt>std::forward<Args>(args)...</tt>
@@ -489,9 +506,9 @@ namespace cds { namespace container {
             already exists.
         */
         template <typename K, typename Func>
             already exists.
         */
         template <typename K, typename Func>
-        std::pair<bool, bool> update( const K& key, Func f, bool bAllowInsert = true )
+        std::pair<bool, bool> update( K&& key, Func f, bool bAllowInsert = true )
         {
         {
-            return update_at( head(), key, f, bAllowInsert );
+            return update_at( head(), std::forward<K>( key ), f, bAllowInsert );
         }
         //@cond
         template <typename K, typename Func>
         }
         //@cond
         template <typename K, typename Func>
@@ -781,21 +798,21 @@ namespace cds { namespace container {
         }
 
         template <typename K>
         }
 
         template <typename K>
-        bool insert_at( head_type& refHead, const K& key )
+        bool insert_at( head_type& refHead, K&& key )
         {
         {
-            return insert_node_at( refHead, alloc_node( key ));
+            return insert_node_at( refHead, alloc_node( std::forward<K>( key )));
         }
 
         template <typename K, typename V>
         }
 
         template <typename K, typename V>
-        bool insert_at( head_type& refHead, const K& key, const V& val )
+        bool insert_at( head_type& refHead, K&& key, V&& val )
         {
         {
-            return insert_node_at( refHead, alloc_node( key, val ));
+            return insert_node_at( refHead, alloc_node( std::forward<K>( key ), std::forward<V>( val )));
         }
 
         template <typename K, typename Func>
         }
 
         template <typename K, typename Func>
-        bool insert_with_at( head_type& refHead, const K& key, Func f )
+        bool insert_with_at( head_type& refHead, K&& key, Func f )
         {
         {
-            scoped_node_ptr pNode( alloc_node( key ));
+            scoped_node_ptr pNode( alloc_node( std::forward<K>( key )));
 
             if ( base_class::insert_at( &refHead, *pNode, [&f](node_type& node){ f( node.m_Data ); } )) {
                 pNode.release();
 
             if ( base_class::insert_at( &refHead, *pNode, [&f](node_type& node){ f( node.m_Data ); } )) {
                 pNode.release();
@@ -829,9 +846,9 @@ namespace cds { namespace container {
         }
 
         template <typename K, typename Func>
         }
 
         template <typename K, typename Func>
-        std::pair<bool, bool> update_at( head_type& refHead, const K& key, Func f, bool bAllowInsert )
+        std::pair<bool, bool> update_at( head_type& refHead, K&& key, Func f, bool bAllowInsert )
         {
         {
-            scoped_node_ptr pNode( alloc_node( key ));
+            scoped_node_ptr pNode( alloc_node( std::forward<K>( key )));
 
             std::pair<bool, bool> ret = base_class::update_at( &refHead, *pNode,
                 [&f]( bool bNew, node_type& node, node_type& ){ f( bNew, node.m_Data ); },
 
             std::pair<bool, bool> ret = base_class::update_at( &refHead, *pNode,
                 [&f]( bool bNew, node_type& node, node_type& ){ f( bNew, node.m_Data ); },
index 12a234265f3305b63e6749f6cc6216f2fa2e087f..4d444ed5a1816f311a7867e0daca44c12dd93f38 100644 (file)
@@ -131,6 +131,7 @@ namespace cds { namespace container {
 #endif
 
         typedef typename base_class::gc           gc;             ///< Garbage collector used
 #endif
 
         typedef typename base_class::gc           gc;             ///< Garbage collector used
+        typedef Traits                            traits;         ///< List traits
         typedef typename base_class::back_off     back_off;       ///< Back-off strategy used
         typedef typename maker::allocator_type    allocator_type; ///< Allocator type used for allocate/deallocate the nodes
         typedef typename base_class::item_counter item_counter;   ///< Item counting policy used
         typedef typename base_class::back_off     back_off;       ///< Back-off strategy used
         typedef typename maker::allocator_type    allocator_type; ///< Allocator type used for allocate/deallocate the nodes
         typedef typename base_class::item_counter item_counter;   ///< Item counting policy used
@@ -140,6 +141,22 @@ namespace cds { namespace container {
 
         static CDS_CONSTEXPR const size_t c_nHazardPtrCount = base_class::c_nHazardPtrCount; ///< Count of hazard pointer required for the algorithm
 
 
         static CDS_CONSTEXPR const size_t c_nHazardPtrCount = base_class::c_nHazardPtrCount; ///< Count of hazard pointer required for the algorithm
 
+        //@cond
+        // Rebind traits (split-list support)
+        template <typename... Options>
+        struct rebind_traits {
+            typedef MichaelKVList<
+                gc
+                , key_type, mapped_type
+                , typename cds::opt::make_options< traits, Options...>::type
+            > type;
+        };
+
+        // Stat selector
+        template <typename Stat>
+        using select_stat_wrapper = typename base_class::template select_stat_wrapper< Stat >;
+        //@endcond
+
     protected:
         //@cond
         typedef typename base_class::value_type   node_type;
     protected:
         //@cond
         typedef typename base_class::value_type   node_type;
@@ -386,9 +403,9 @@ namespace cds { namespace container {
             Returns \p true if inserting successful, \p false otherwise.
         */
         template <typename K>
             Returns \p true if inserting successful, \p false otherwise.
         */
         template <typename K>
-        bool insert( const K& key )
+        bool insert( K&& key )
         {
         {
-            return insert_at( head(), key );
+            return insert_at( head(), std::forward<K>( key ));
         }
 
         /// Inserts new node with a key and a value
         }
 
         /// Inserts new node with a key and a value
@@ -402,12 +419,12 @@ namespace cds { namespace container {
             Returns \p true if inserting successful, \p false otherwise.
         */
         template <typename K, typename V>
             Returns \p true if inserting successful, \p false otherwise.
         */
         template <typename K, typename V>
-        bool insert( const K& key, const V& val )
+        bool insert( K&& key, V&& val )
         {
             // We cannot use insert with functor here
             // because we cannot lock inserted node for updating
             // Therefore, we use separate function
         {
             // We cannot use insert with functor here
             // because we cannot lock inserted node for updating
             // Therefore, we use separate function
-            return insert_at( head(), key, val );
+            return insert_at( head(), std::forward<K>( key ), std::forward<V>( val ));
         }
 
         /// Inserts new node and initialize it by a functor
         }
 
         /// Inserts new node and initialize it by a functor
@@ -439,9 +456,9 @@ namespace cds { namespace container {
             @warning See \ref cds_intrusive_item_creating "insert item troubleshooting"
         */
         template <typename K, typename Func>
             @warning See \ref cds_intrusive_item_creating "insert item troubleshooting"
         */
         template <typename K, typename Func>
-        bool insert_with( const K& key, Func func )
+        bool insert_with( K&& key, Func func )
         {
         {
-            return insert_with_at( head(), key, func );
+            return insert_with_at( head(), std::forward<K>( key ), func );
         }
 
         /// Updates data by \p key
         }
 
         /// Updates data by \p key
@@ -474,9 +491,9 @@ namespace cds { namespace container {
             @warning See \ref cds_intrusive_item_creating "insert item troubleshooting"
         */
         template <typename K, typename Func>
             @warning See \ref cds_intrusive_item_creating "insert item troubleshooting"
         */
         template <typename K, typename Func>
-        std::pair<bool, bool> update( K const& key, Func f, bool bAllowInsert = true )
+        std::pair<bool, bool> update( K&& key, Func f, bool bAllowInsert = true )
         {
         {
-            return update_at( head(), key, f, bAllowInsert );
+            return update_at( head(), std::forward<K>( key ), f, bAllowInsert );
         }
         //@cond
         template <typename K, typename Func>
         }
         //@cond
         template <typename K, typename Func>
@@ -783,21 +800,21 @@ namespace cds { namespace container {
         }
 
         template <typename K>
         }
 
         template <typename K>
-        bool insert_at( head_type& refHead, const K& key )
+        bool insert_at( head_type& refHead, K&& key )
         {
         {
-            return insert_node_at( refHead, alloc_node( key ));
+            return insert_node_at( refHead, alloc_node( std::forward<K>( key )));
         }
 
         template <typename K, typename V>
         }
 
         template <typename K, typename V>
-        bool insert_at( head_type& refHead, const K& key, const V& val )
+        bool insert_at( head_type& refHead, K&& key, V&& val )
         {
         {
-            return insert_node_at( refHead, alloc_node( key, val ));
+            return insert_node_at( refHead, alloc_node( std::forward<K>( key ), std::forward<V>( val )));
         }
 
         template <typename K, typename Func>
         }
 
         template <typename K, typename Func>
-        bool insert_with_at( head_type& refHead, const K& key, Func f )
+        bool insert_with_at( head_type& refHead, K&& key, Func f )
         {
         {
-            scoped_node_ptr pNode( alloc_node( key ));
+            scoped_node_ptr pNode( alloc_node( std::forward<K>( key )));
 
             if ( base_class::insert_at( refHead, *pNode, [&f](node_type& node){ f( node.m_Data ); })) {
                 pNode.release();
 
             if ( base_class::insert_at( refHead, *pNode, [&f](node_type& node){ f( node.m_Data ); })) {
                 pNode.release();
@@ -813,9 +830,9 @@ namespace cds { namespace container {
         }
 
         template <typename K, typename Func>
         }
 
         template <typename K, typename Func>
-        std::pair<bool, bool> update_at( head_type& refHead, const K& key, Func f, bool bAllowInsert )
+        std::pair<bool, bool> update_at( head_type& refHead, K&& key, Func f, bool bAllowInsert )
         {
         {
-            scoped_node_ptr pNode( alloc_node( key ));
+            scoped_node_ptr pNode( alloc_node( std::forward<K>( key )));
 
             std::pair<bool, bool> ret = base_class::update_at( refHead, *pNode,
                 [&f]( bool bNew, node_type& node, node_type& ){ f( bNew, node.m_Data ); },
 
             std::pair<bool, bool> ret = base_class::update_at( refHead, *pNode,
                 [&f]( bool bNew, node_type& node, node_type& ){ f( bNew, node.m_Data ); },
index 38bce26dba7c98b5921f47918a265b3949508ec3..123ef86923a98a4f4dd93acb738adce87ef060fa 100644 (file)
@@ -32,6 +32,7 @@
 #define CDSLIB_CONTAINER_MICHAEL_MAP_H
 
 #include <cds/container/details/michael_map_base.h>
 #define CDSLIB_CONTAINER_MICHAEL_MAP_H
 
 #include <cds/container/details/michael_map_base.h>
+#include <cds/container/details/iterable_list_base.h>
 #include <cds/details/allocator.h>
 
 namespace cds { namespace container {
 #include <cds/details/allocator.h>
 
 namespace cds { namespace container {
@@ -52,10 +53,10 @@ namespace cds { namespace container {
         - \p GC - Garbage collector used. You may use any \ref cds_garbage_collector "Garbage collector"
             from the \p libcds library.
             Note the \p GC must be the same as the GC used for \p OrderedList
         - \p GC - Garbage collector used. You may use any \ref cds_garbage_collector "Garbage collector"
             from the \p libcds library.
             Note the \p GC must be the same as the GC used for \p OrderedList
-        - \p OrderedList - ordered key-value list implementation used as bucket for hash map, for example, \p MichaelKVList
-            or \p LazyKVList. The ordered list implementation specifies the \p Key and \p Value types stored in the hash-map,
-            the reclamation schema \p GC used by hash-map, the comparison functor for the type \p Key and other features
-            specific for the ordered list.
+        - \p OrderedList - ordered key-value list implementation used as bucket for hash map, for example, \p MichaelKVList,
+            \p LazyKVList, \p IterableKVList. The ordered list implementation specifies the \p Key and \p Value types
+            stored in the hash-map, the reclamation schema \p GC used by hash-map, the comparison functor for the type \p Key
+            and other features specific for the ordered list.
         - \p Traits - map traits, default is \p michael_map::traits.
             Instead of defining \p Traits struct you may use option-based syntax with \p michael_map::make_traits metafunction.
 
         - \p Traits - map traits, default is \p michael_map::traits.
             Instead of defining \p Traits struct you may use option-based syntax with \p michael_map::make_traits metafunction.
 
@@ -147,60 +148,72 @@ namespace cds { namespace container {
     class MichaelHashMap
     {
     public:
     class MichaelHashMap
     {
     public:
-        typedef GC          gc;          ///< Garbage collector
-        typedef OrderedList bucket_type; ///< type of ordered list to be used as a bucket
-        typedef Traits      traits;      ///< Map traits
+        typedef GC          gc;             ///< Garbage collector
+        typedef OrderedList ordered_list;   ///< type of ordered list to be used as a bucket
+        typedef Traits      traits;         ///< Map traits
 
 
-        typedef typename bucket_type::key_type    key_type;    ///< key type
-        typedef typename bucket_type::mapped_type mapped_type; ///< value type
-        typedef typename bucket_type::value_type  value_type;  ///< key/value pair stored in the map
+        typedef typename ordered_list::key_type    key_type;    ///< key type
+        typedef typename ordered_list::mapped_type mapped_type; ///< value type
+        typedef typename ordered_list::value_type  value_type;  ///< key/value pair stored in the map
+        typedef typename traits::allocator         allocator;   ///< Bucket table allocator
 
 
-        typedef typename bucket_type::key_comparator key_comparator;  ///< key compare functor
+        typedef typename ordered_list::key_comparator key_comparator;  ///< key compare functor
+        typedef typename ordered_list::stat           stat;           ///< Internal statistics
 
         /// Hash functor for \ref key_type and all its derivatives that you use
         typedef typename cds::opt::v::hash_selector< typename traits::hash >::type hash;
         typedef typename traits::item_counter  item_counter;   ///< Item counter type
 
 
         /// Hash functor for \ref key_type and all its derivatives that you use
         typedef typename cds::opt::v::hash_selector< typename traits::hash >::type hash;
         typedef typename traits::item_counter  item_counter;   ///< Item counter type
 
-        /// Bucket table allocator
-        typedef cds::details::Allocator< bucket_type, typename traits::allocator >  bucket_table_allocator;
-        typedef typename bucket_type::guarded_ptr  guarded_ptr; ///< Guarded pointer
+        // GC and OrderedList::gc must be the same
+        static_assert( std::is_same<gc, typename ordered_list::gc>::value, "GC and OrderedList::gc must be the same");
 
 
-        static CDS_CONSTEXPR const size_t c_nHazardPtrCount = bucket_type::c_nHazardPtrCount; ///< Count of hazard pointer required
+        // atomicity::empty_item_counter is not allowed as a item counter
+        static_assert( !std::is_same<item_counter, atomicity::empty_item_counter>::value,
+                        "atomicity::empty_item_counter is not allowed as a item counter");
 
 
-    protected:
-        item_counter    m_ItemCounter; ///< Item counter
-        hash            m_HashFunctor; ///< Hash functor
-        bucket_type *   m_Buckets;     ///< bucket table
+        static CDS_CONSTEXPR const size_t c_nHazardPtrCount = ordered_list::c_nHazardPtrCount; ///< Count of hazard pointer required
+
+#ifdef CDS_DOXYGEN_INVOKED
+        /// Wrapped internal statistics for \p ordered_list
+        typedef implementatin_specific bucket_stat;
+#else
+        typedef typename ordered_list::template select_stat_wrapper< typename ordered_list::stat > bucket_stat;
+#endif
+
+#ifdef CDS_DOXYGEN_INVOKED
+        /// Internal bucket type - rebind \p ordered_list with empty item counter and wrapped internal statistics
+        typedef modified_ordered_list internal_bucket_type;
+#else
+        typedef typename ordered_list::template rebind_traits<
+            cds::opt::item_counter< cds::atomicity::empty_item_counter >
+            , cds::opt::stat< typename bucket_stat::wrapped_stat >
+        >::type internal_bucket_type;
+#endif
+
+        /// Guarded pointer - a result of \p get() and \p extract() functions
+        typedef typename internal_bucket_type::guarded_ptr guarded_ptr;
 
 
-    private:
         //@cond
         //@cond
-        const size_t    m_nHashBitmask;
+        /// Bucket table allocator
+        typedef typename allocator::template rebind< internal_bucket_type >::other bucket_table_allocator;
         //@endcond
 
     protected:
         //@cond
         //@endcond
 
     protected:
         //@cond
-        /// Calculates hash value of \p key
-        template <typename Q>
-        size_t hash_value( Q const& key ) const
-        {
-            return m_HashFunctor( key ) & m_nHashBitmask;
-        }
-
-        /// Returns the bucket (ordered list) for \p key
-        template <typename Q>
-        bucket_type&    bucket( Q const& key )
-        {
-            return m_Buckets[ hash_value( key ) ];
-        }
+        const size_t            m_nHashBitmask;
+        internal_bucket_type *  m_Buckets;     ///< bucket table
+        item_counter            m_ItemCounter; ///< Item counter
+        hash                    m_HashFunctor; ///< Hash functor
+        typename bucket_stat::stat  m_Stat;   ///< Internal statistics
         //@endcond
 
     protected:
         //@cond
         /// Forward iterator
         template <bool IsConst>
         //@endcond
 
     protected:
         //@cond
         /// Forward iterator
         template <bool IsConst>
-        class iterator_type: private cds::intrusive::michael_set::details::iterator< bucket_type, IsConst >
+        class iterator_type: private cds::intrusive::michael_set::details::iterator< internal_bucket_type, IsConst >
         {
         {
-            typedef cds::intrusive::michael_set::details::iterator< bucket_type, IsConst >  base_class;
+            typedef cds::intrusive::michael_set::details::iterator< internal_bucket_type, IsConst >  base_class;
             friend class MichaelHashMap;
 
         protected:
             friend class MichaelHashMap;
 
         protected:
@@ -288,38 +301,44 @@ namespace cds { namespace container {
     //@{
         /// Forward iterator
         /**
     //@{
         /// Forward iterator
         /**
-            The iteration is unordered.
-            The iterator object is thread-safe: the element pointed by the iterator object is guarded,
-            so, the element cannot be reclaimed while the iterator object is alive.
-            However, passing an iterator object between threads is dangerous.
-
-            @warning Due to concurrent nature of Michael's map it is not guarantee that you can iterate
-            all elements in the map: any concurrent deletion can exclude the element
-            pointed by the iterator from the map, and your iteration can be terminated
-            before end of the map. Therefore, such iteration is more suitable for debugging purpose only.
-
-            Remember, each iterator object requires an additional hazard pointer, that may be
-            a limited resource for \p GC like \p gc::HP (for \p gc::DHP the count of
-            guards is unlimited).
-
-            The iterator class supports the following minimalistic interface:
+            The forward iterator for Michael's map has some features:
+            - it has no post-increment operator
+            - to protect the value, the iterator contains a GC-specific guard + another guard is required locally for increment operator.
+              For some GC (like as \p gc::HP), a guard is a limited resource per thread, so an exception (or assertion) "no free guard"
+              may be thrown if the limit of guard count per thread is exceeded.
+            - The iterator cannot be moved across thread boundary because it contains thread-private GC's guard.
+
+            Iterator thread safety depends on type of \p OrderedList:
+            - for \p MichaelKVList and \p LazyKVList: iterator guarantees safety even if you delete the item that iterator points to
+              because that item is guarded by hazard pointer.
+              However, in case of concurrent deleting operations it is no guarantee that you iterate all item in the map.
+              Moreover, a crash is possible when you try to iterate the next element that has been deleted by concurrent thread.
+              Use this iterator on the concurrent container for debugging purpose only.
+            - for \p IterableList: iterator is thread-safe. You may use it freely in concurrent environment.
+
+            The iterator interface:
             \code
             \code
-            struct iterator {
-                // Default ctor
+            class iterator {
+            public:
+                // Default constructor
                 iterator();
 
                 iterator();
 
-                // Copy ctor
-                iterator( iterator const& s);
+                // Copy construtor
+                iterator( iterator const& src );
 
 
+                // Dereference operator
                 value_type * operator ->() const;
                 value_type * operator ->() const;
+
+                // Dereference operator
                 value_type& operator *() const;
 
                 value_type& operator *() const;
 
-                // Pre-increment
+                // Preincrement operator
                 iterator& operator ++();
 
                 iterator& operator ++();
 
-                // Copy assignment
+                // Assignment operator
                 iterator& operator = (iterator const& src);
 
                 iterator& operator = (iterator const& src);
 
+                // Equality operators
                 bool operator ==(iterator const& i ) const;
                 bool operator !=(iterator const& i ) const;
             };
                 bool operator ==(iterator const& i ) const;
                 bool operator !=(iterator const& i ) const;
             };
@@ -338,7 +357,7 @@ namespace cds { namespace container {
         */
         iterator begin()
         {
         */
         iterator begin()
         {
-            return iterator( m_Buckets[0].begin(), m_Buckets, m_Buckets + bucket_count() );
+            return iterator( bucket_begin()->begin(), bucket_begin(), bucket_end() );
         }
 
         /// Returns an iterator that addresses the location succeeding the last element in a map
         }
 
         /// Returns an iterator that addresses the location succeeding the last element in a map
@@ -349,7 +368,7 @@ namespace cds { namespace container {
         */
         iterator end()
         {
         */
         iterator end()
         {
-            return iterator( m_Buckets[bucket_count() - 1].end(), m_Buckets + bucket_count() - 1, m_Buckets + bucket_count() );
+            return iterator( bucket_end()[-1].end(), bucket_end() - 1, bucket_end() );
         }
 
         /// Returns a forward const iterator addressing the first element in a map
         }
 
         /// Returns a forward const iterator addressing the first element in a map
@@ -375,18 +394,6 @@ namespace cds { namespace container {
         }
     //@}
 
         }
     //@}
 
-    private:
-        //@cond
-        const_iterator get_const_begin() const
-        {
-            return const_iterator( const_cast<bucket_type const&>(m_Buckets[0]).begin(), m_Buckets, m_Buckets + bucket_count() );
-        }
-        const_iterator get_const_end() const
-        {
-            return const_iterator( const_cast<bucket_type const&>(m_Buckets[bucket_count() - 1]).end(), m_Buckets + bucket_count() - 1, m_Buckets + bucket_count() );
-        }
-        //@endcond
-
     public:
         /// Initializes the map
         /** @anchor cds_nonintrusive_MichaelHashMap_hp_ctor
     public:
         /// Initializes the map
         /** @anchor cds_nonintrusive_MichaelHashMap_hp_ctor
@@ -401,23 +408,22 @@ namespace cds { namespace container {
         MichaelHashMap(
             size_t nMaxItemCount,   ///< estimation of max item count in the hash map
             size_t nLoadFactor      ///< load factor: estimation of max number of items in the bucket
         MichaelHashMap(
             size_t nMaxItemCount,   ///< estimation of max item count in the hash map
             size_t nLoadFactor      ///< load factor: estimation of max number of items in the bucket
-        ) : m_nHashBitmask( michael_map::details::init_hash_bitmask( nMaxItemCount, nLoadFactor ))
+            )
+            : m_nHashBitmask( michael_map::details::init_hash_bitmask( nMaxItemCount, nLoadFactor ))
+            , m_Buckets( bucket_table_allocator().allocate( bucket_count() ) )
         {
         {
-            // GC and OrderedList::gc must be the same
-            static_assert( std::is_same<gc, typename bucket_type::gc>::value, "GC and OrderedList::gc must be the same");
-
-            // atomicity::empty_item_counter is not allowed as a item counter
-            static_assert( !std::is_same<item_counter, atomicity::empty_item_counter>::value,
-                           "atomicity::empty_item_counter is not allowed as a item counter");
-
-            m_Buckets = bucket_table_allocator().NewArray( bucket_count() );
+            for ( auto it = m_Buckets, itEnd = m_Buckets + bucket_count(); it != itEnd; ++it )
+                construct_bucket<bucket_stat>( it );
         }
 
         /// Clears hash map and destroys it
         ~MichaelHashMap()
         {
             clear();
         }
 
         /// Clears hash map and destroys it
         ~MichaelHashMap()
         {
             clear();
-            bucket_table_allocator().Delete( m_Buckets, bucket_count() );
+
+            for ( auto it = m_Buckets, itEnd = m_Buckets + bucket_count(); it != itEnd; ++it )
+                it->~internal_bucket_type();
+            bucket_table_allocator().deallocate( m_Buckets, bucket_count() );
         }
 
         /// Inserts new node with key and default value
         }
 
         /// Inserts new node with key and default value
@@ -432,9 +438,9 @@ namespace cds { namespace container {
             Returns \p true if inserting successful, \p false otherwise.
         */
         template <typename K>
             Returns \p true if inserting successful, \p false otherwise.
         */
         template <typename K>
-        bool insert( const K& key )
+        bool insert( K&& key )
         {
         {
-            const bool bRet = bucket( key ).insert( key );
+            const bool bRet = bucket( key ).insert( std::forward<K>( key ));
             if ( bRet )
                 ++m_ItemCounter;
             return bRet;
             if ( bRet )
                 ++m_ItemCounter;
             return bRet;
@@ -452,9 +458,9 @@ namespace cds { namespace container {
             Returns \p true if \p val is inserted into the map, \p false otherwise.
         */
         template <typename K, typename V>
             Returns \p true if \p val is inserted into the map, \p false otherwise.
         */
         template <typename K, typename V>
-        bool insert( K const& key, V const& val )
+        bool insert( K&& key, V&& val )
         {
         {
-            const bool bRet = bucket( key ).insert( key, val );
+            const bool bRet = bucket( key ).insert( std::forward<K>( key ), std::forward<V>( val ));
             if ( bRet )
                 ++m_ItemCounter;
             return bRet;
             if ( bRet )
                 ++m_ItemCounter;
             return bRet;
@@ -492,9 +498,9 @@ namespace cds { namespace container {
             synchronization.
         */
         template <typename K, typename Func>
             synchronization.
         */
         template <typename K, typename Func>
-        bool insert_with( const K& key, Func func )
+        bool insert_with( K&& key, Func func )
         {
         {
-            const bool bRet = bucket( key ).insert_with( key, func );
+            const bool bRet = bucket( key ).insert_with( std::forward<K>( key ), func );
             if ( bRet )
                 ++m_ItemCounter;
             return bRet;
             if ( bRet )
                 ++m_ItemCounter;
             return bRet;
@@ -509,7 +515,9 @@ namespace cds { namespace container {
             (note that in this case the \ref key_type should be constructible from type \p K).
             Otherwise, if \p key is found, the functor \p func is called with item found.
 
             (note that in this case the \ref key_type should be constructible from type \p K).
             Otherwise, if \p key is found, the functor \p func is called with item found.
 
-            The functor \p Func signature is:
+            The functor \p func signature depends of \p OrderedList:
+
+            <b>for \p MichaelKVList, \p LazyKVList</b>
             \code
                 struct my_functor {
                     void operator()( bool bNew, value_type& item );
             \code
                 struct my_functor {
                     void operator()( bool bNew, value_type& item );
@@ -521,18 +529,30 @@ namespace cds { namespace container {
 
             The functor may change any fields of the \p item.second that is \p mapped_type.
 
 
             The functor may change any fields of the \p item.second that is \p mapped_type.
 
-            Returns <tt> std::pair<bool, bool> </tt> where \p first is true if operation is successful,
+            <b>for \p IterableKVList</b>
+            \code
+                void func( value_type& val, value_type * old );
+            \endcode
+            where
+            - \p val - a new data constructed from \p key
+            - \p old - old value that will be retired. If new item has been inserted then \p old is \p nullptr.
+
+            The functor may change non-key fields of \p val; however, \p func must guarantee
+            that during changing no any other modifications could be made on this item by concurrent threads.
+
+            @return <tt> std::pair<bool, bool> </tt> where \p first is true if operation is successful,
             \p second is true if new item has been added or \p false if the item with \p key
             already exists.
 
             \p second is true if new item has been added or \p false if the item with \p key
             already exists.
 
-            @warning For \ref cds_nonintrusive_MichaelKVList_gc "MichaelKVList" as the bucket see \ref cds_intrusive_item_creating "insert item troubleshooting".
+            @warning For \ref cds_nonintrusive_MichaelKVList_gc "MichaelKVList" and \ref cds_nonintrusive_IterableKVList_gc "IterableKVList" 
+            as the bucket see \ref cds_intrusive_item_creating "insert item troubleshooting".
             \ref cds_nonintrusive_LazyKVList_gc "LazyKVList" provides exclusive access to inserted item and does not require any node-level
             synchronization.
         */
         template <typename K, typename Func >
             \ref cds_nonintrusive_LazyKVList_gc "LazyKVList" provides exclusive access to inserted item and does not require any node-level
             synchronization.
         */
         template <typename K, typename Func >
-        std::pair<bool, bool> update( K const& key, Func func, bool bAllowInsert = true )
+        std::pair<bool, bool> update( K&& key, Func func, bool bAllowInsert = true )
         {
         {
-            std::pair<bool, bool> bRet = bucket( key ).update( key, func, bAllowInsert );
+            std::pair<bool, bool> bRet = bucket( key ).update( std::forward<K>( key ), func, bAllowInsert );
             if ( bRet.first && bRet.second )
                 ++m_ItemCounter;
             return bRet;
             if ( bRet.first && bRet.second )
                 ++m_ItemCounter;
             return bRet;
@@ -549,6 +569,34 @@ namespace cds { namespace container {
         }
         //@endcond
 
         }
         //@endcond
 
+        /// Inserts or updates the node (only for \p IterableKVList)
+        /**
+            The operation performs inserting or changing data with lock-free manner.
+
+            If the item \p val is not found in the map, then \p val is inserted iff \p bAllowInsert is \p true.
+            Otherwise, the current element is changed to \p val, the old element will be retired later.
+
+            Returns std::pair<bool, bool> where \p first is \p true if operation is successful,
+            \p second is \p true if \p val has been added or \p false if the item with that key
+            already in the map.
+        */
+        template <typename Q, typename V>
+#ifdef CDS_DOXYGEN_INVOKED
+        std::pair<bool, bool>
+#else
+        typename std::enable_if< 
+            std::is_same< Q, Q>::value && is_iterable_list< ordered_list >::value,
+            std::pair<bool, bool>
+        >::type
+#endif
+        upsert( Q&& key, V&& val, bool bAllowInsert = true )
+        {
+            std::pair<bool, bool> bRet = bucket( val ).upsert( std::forward<Q>( key ), std::forward<V>( val ), bAllowInsert );
+            if ( bRet.second )
+                ++m_ItemCounter;
+            return bRet;
+        }
+
         /// For key \p key inserts data of type \p mapped_type created from \p args
         /**
             \p key_type should be constructible from type \p K
         /// For key \p key inserts data of type \p mapped_type created from \p args
         /**
             \p key_type should be constructible from type \p K
@@ -845,6 +893,63 @@ namespace cds { namespace container {
         {
             return m_nHashBitmask + 1;
         }
         {
             return m_nHashBitmask + 1;
         }
+
+        /// Returns const reference to internal statistics
+        stat const& statistics() const
+        {
+            return m_Stat;
+        }
+
+    protected:
+        //@cond
+        /// Calculates hash value of \p key
+        template <typename Q>
+        size_t hash_value( Q const& key ) const
+        {
+            return m_HashFunctor( key ) & m_nHashBitmask;
+        }
+
+        /// Returns the bucket (ordered list) for \p key
+        template <typename Q>
+        internal_bucket_type& bucket( Q const& key )
+        {
+            return m_Buckets[hash_value( key )];
+        }
+        //@endcond
+
+    private:
+        //@cond
+        internal_bucket_type* bucket_begin() const
+        {
+            return m_Buckets;
+        }
+
+        internal_bucket_type* bucket_end() const
+        {
+            return m_Buckets + bucket_count();
+        }
+
+        const_iterator get_const_begin() const
+        {
+            return const_iterator( bucket_begin()->cbegin(), bucket_begin(), bucket_end() );
+        }
+        const_iterator get_const_end() const
+        {
+            return const_iterator( (bucket_end() - 1)->cend(), bucket_end() - 1, bucket_end() );
+        }
+
+        template <typename Stat>
+        typename std::enable_if< Stat::empty >::type construct_bucket( internal_bucket_type* bucket )
+        {
+            new (bucket) internal_bucket_type;
+        }
+
+        template <typename Stat>
+        typename std::enable_if< !Stat::empty >::type construct_bucket( internal_bucket_type* bucket )
+        {
+            new (bucket) internal_bucket_type( m_Stat );
+        }
+        //@endcond
     };
 }}  // namespace cds::container
 
     };
 }}  // namespace cds::container
 
index bff190311ff3caacd6bb9c061310f1046178e052..c324710bc7eebdc6fd3838209c689362c54b60de 100644 (file)
@@ -463,8 +463,7 @@ namespace cds { namespace container {
             The operation performs inserting or changing data with lock-free manner.
 
             If the item \p val is not found in the set, then \p val is inserted iff \p bAllowInsert is \p true.
             The operation performs inserting or changing data with lock-free manner.
 
             If the item \p val is not found in the set, then \p val is inserted iff \p bAllowInsert is \p true.
-            Otherwise, the current element is changed to \p val, the old element will be retired later
-            by call \p Traits::disposer.
+            Otherwise, the current element is changed to \p val, the old element will be retired later.
 
             Returns std::pair<bool, bool> where \p first is \p true if operation is successful,
             \p second is \p true if \p val has been added or \p false if the item with that key
 
             Returns std::pair<bool, bool> where \p first is \p true if operation is successful,
             \p second is \p true if \p val has been added or \p false if the item with that key
index d81d5d90b6cedd1a5a9b50824d8a052ddd3bcbf6..0a0818844ce806796b839687b2ea4f0ec6bf16b8 100644 (file)
@@ -35,6 +35,8 @@
     <ClCompile Include="..\..\..\test\unit\map\feldman_hashset_rcu_gpt.cpp" />\r
     <ClCompile Include="..\..\..\test\unit\map\feldman_hashset_rcu_shb.cpp" />\r
     <ClCompile Include="..\..\..\test\unit\map\feldman_hashset_rcu_sht.cpp" />\r
     <ClCompile Include="..\..\..\test\unit\map\feldman_hashset_rcu_gpt.cpp" />\r
     <ClCompile Include="..\..\..\test\unit\map\feldman_hashset_rcu_shb.cpp" />\r
     <ClCompile Include="..\..\..\test\unit\map\feldman_hashset_rcu_sht.cpp" />\r
+    <ClCompile Include="..\..\..\test\unit\map\michael_iterable_dhp.cpp" />\r
+    <ClCompile Include="..\..\..\test\unit\map\michael_iterable_hp.cpp" />\r
     <ClCompile Include="..\..\..\test\unit\map\michael_lazy_dhp.cpp" />\r
     <ClCompile Include="..\..\..\test\unit\map\michael_lazy_hp.cpp" />\r
     <ClCompile Include="..\..\..\test\unit\map\michael_lazy_nogc.cpp" />\r
     <ClCompile Include="..\..\..\test\unit\map\michael_lazy_dhp.cpp" />\r
     <ClCompile Include="..\..\..\test\unit\map\michael_lazy_hp.cpp" />\r
     <ClCompile Include="..\..\..\test\unit\map\michael_lazy_nogc.cpp" />\r
     <ClInclude Include="..\..\..\test\unit\map\test_map_hp.h" />\r
     <ClInclude Include="..\..\..\test\unit\map\test_map_nogc.h" />\r
     <ClInclude Include="..\..\..\test\unit\map\test_map_rcu.h" />\r
     <ClInclude Include="..\..\..\test\unit\map\test_map_hp.h" />\r
     <ClInclude Include="..\..\..\test\unit\map\test_map_nogc.h" />\r
     <ClInclude Include="..\..\..\test\unit\map\test_map_rcu.h" />\r
+    <ClInclude Include="..\..\..\test\unit\map\test_michael_iterable.h" />\r
+    <ClInclude Include="..\..\..\test\unit\map\test_michael_iterable_hp.h" />\r
     <ClInclude Include="..\..\..\test\unit\map\test_michael_lazy_rcu.h" />\r
     <ClInclude Include="..\..\..\test\unit\map\test_michael_michael_rcu.h" />\r
     <ClInclude Include="..\..\..\test\unit\map\test_skiplist_hp.h" />\r
     <ClInclude Include="..\..\..\test\unit\map\test_michael_lazy_rcu.h" />\r
     <ClInclude Include="..\..\..\test\unit\map\test_michael_michael_rcu.h" />\r
     <ClInclude Include="..\..\..\test\unit\map\test_skiplist_hp.h" />\r
index 46d394f84b2024ffcbc589d8a678258326ef26fa..e25cb3a74ecffc2142795edca994b5910899cb0e 100644 (file)
     <ClCompile Include="..\..\..\test\unit\map\feldman_hashset_rcu_sht.cpp">\r
       <Filter>Source Files\FeldmanHashMap</Filter>\r
     </ClCompile>\r
     <ClCompile Include="..\..\..\test\unit\map\feldman_hashset_rcu_sht.cpp">\r
       <Filter>Source Files\FeldmanHashMap</Filter>\r
     </ClCompile>\r
+    <ClCompile Include="..\..\..\test\unit\map\michael_iterable_hp.cpp">\r
+      <Filter>Source Files\MichaelMap</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\test\unit\map\michael_iterable_dhp.cpp">\r
+      <Filter>Source Files\MichaelMap</Filter>\r
+    </ClCompile>\r
   </ItemGroup>\r
   <ItemGroup>\r
     <ClInclude Include="..\..\..\test\unit\map\test_map.h">\r
   </ItemGroup>\r
   <ItemGroup>\r
     <ClInclude Include="..\..\..\test\unit\map\test_map.h">\r
     <ClInclude Include="..\..\..\test\unit\map\test_feldman_hashmap_rcu.h">\r
       <Filter>Header Files</Filter>\r
     </ClInclude>\r
     <ClInclude Include="..\..\..\test\unit\map\test_feldman_hashmap_rcu.h">\r
       <Filter>Header Files</Filter>\r
     </ClInclude>\r
+    <ClInclude Include="..\..\..\test\unit\map\test_michael_iterable.h">\r
+      <Filter>Header Files</Filter>\r
+    </ClInclude>\r
+    <ClInclude Include="..\..\..\test\unit\map\test_michael_iterable_hp.h">\r
+      <Filter>Header Files</Filter>\r
+    </ClInclude>\r
   </ItemGroup>\r
 </Project>
\ No newline at end of file
   </ItemGroup>\r
 </Project>
\ No newline at end of file
index d4a4565a05ef32a670314535300edd6af882400f..b8a09ccdbd85b899a3d0df4f37f0e4565ca78301 100644 (file)
@@ -9,6 +9,8 @@ set(CDSGTEST_MAP_SOURCES
     feldman_hashset_rcu_gpt.cpp
     feldman_hashset_rcu_shb.cpp
     feldman_hashset_rcu_sht.cpp
     feldman_hashset_rcu_gpt.cpp
     feldman_hashset_rcu_shb.cpp
     feldman_hashset_rcu_sht.cpp
+    michael_iterable_hp.cpp
+    michael_iterable_dhp.cpp
     michael_lazy_hp.cpp
     michael_lazy_dhp.cpp
     michael_lazy_nogc.cpp
     michael_lazy_hp.cpp
     michael_lazy_dhp.cpp
     michael_lazy_nogc.cpp
diff --git a/test/unit/map/michael_iterable_dhp.cpp b/test/unit/map/michael_iterable_dhp.cpp
new file mode 100644 (file)
index 0000000..70637b1
--- /dev/null
@@ -0,0 +1,197 @@
+/*
+    This file is a part of libcds - Concurrent Data Structures library
+
+    (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016
+
+    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:
+
+    * Redistributions of source code must retain the above copyright notice, this
+      list of conditions and the following disclaimer.
+
+    * Redistributions in binary form must reproduce the above copyright notice,
+      this list of conditions and the following disclaimer in the documentation
+      and/or other materials provided with the distribution.
+
+    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+    AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+    IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+    DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+    FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+    DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+    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.
+*/
+
+#include "test_michael_iterable_hp.h"
+
+#include <cds/container/iterable_kvlist_dhp.h>
+#include <cds/container/michael_map.h>
+
+namespace {
+
+    namespace cc = cds::container;
+    typedef cds::gc::DHP gc_type;
+
+    class MichaelIterableMap_DHP: public cds_test::michael_iterable_hp
+    {
+    protected:
+        typedef cds_test::michael_iterable_hp base_class;
+
+        void SetUp()
+        {
+            typedef cc::IterableKVList< gc_type, key_type, value_type > list_type;
+            typedef cc::MichaelHashMap< gc_type, list_type >   map_type;
+
+            cds::gc::dhp::GarbageCollector::Construct( 16, map_type::c_nHazardPtrCount );
+            cds::threading::Manager::attachThread();
+        }
+
+        void TearDown()
+        {
+            cds::threading::Manager::detachThread();
+            cds::gc::dhp::GarbageCollector::Destruct();
+        }
+    };
+
+    TEST_F( MichaelIterableMap_DHP, compare )
+    {
+        typedef cc::IterableKVList< gc_type, key_type, value_type,
+            typename cc::iterable_list::make_traits<
+                cds::opt::compare< cmp >
+            >::type
+        > list_type;
+
+        typedef cc::MichaelHashMap< gc_type, list_type, 
+            typename cc::michael_map::make_traits<
+                cds::opt::hash< hash1 >
+            >::type
+        > map_type;
+
+        map_type m( kSize, 2 );
+        test( m );
+    }
+
+    TEST_F( MichaelIterableMap_DHP, less )
+    {
+        typedef cc::IterableKVList< gc_type, key_type, value_type,
+            typename cc::iterable_list::make_traits<
+                cds::opt::less< less >
+            >::type
+        > list_type;
+
+        typedef cc::MichaelHashMap< gc_type, list_type, 
+            typename cc::michael_map::make_traits<
+                cds::opt::hash< hash1 >
+            >::type
+        > map_type;
+
+        map_type m( kSize, 1 );
+        test( m );
+    }
+
+    TEST_F( MichaelIterableMap_DHP, cmpmix )
+    {
+        typedef cc::IterableKVList< gc_type, key_type, value_type,
+            typename cc::iterable_list::make_traits<
+                cds::opt::less< less >
+                ,cds::opt::compare< cmp >
+            >::type
+        > list_type;
+
+        typedef cc::MichaelHashMap< gc_type, list_type, 
+            typename cc::michael_map::make_traits<
+                cds::opt::hash< hash1 >
+            >::type
+        > map_type;
+
+        map_type m( kSize, 2 );
+        test( m );
+    }
+
+    TEST_F( MichaelIterableMap_DHP, backoff )
+    {
+        struct list_traits: public cc::iterable_list::traits
+        {
+            typedef cmp compare;
+            typedef cds::backoff::exponential<cds::backoff::pause, cds::backoff::yield> back_off;
+        };
+        typedef cc::IterableKVList< gc_type, key_type, value_type, list_traits > list_type;
+
+        struct map_traits: public cc::michael_map::traits
+        {
+            typedef hash1 hash;
+            typedef cds::atomicity::item_counter item_counter;
+        };
+        typedef cc::MichaelHashMap< gc_type, list_type, map_traits > map_type;
+
+        map_type m( kSize, 4 );
+        test( m );
+    }
+
+    TEST_F( MichaelIterableMap_DHP, seq_cst )
+    {
+        struct list_traits: public cc::iterable_list::traits
+        {
+            typedef cmp compare;
+            typedef cds::backoff::yield back_off;
+            typedef cds::opt::v::sequential_consistent memory_model;
+        };
+        typedef cc::IterableKVList< gc_type, key_type, value_type, list_traits > list_type;
+
+        struct map_traits: public cc::michael_map::traits
+        {
+            typedef hash1 hash;
+        };
+        typedef cc::MichaelHashMap< gc_type, list_type, map_traits > map_type;
+
+        map_type s( kSize, 8 );
+        test( s );
+    }
+
+    TEST_F( MichaelIterableMap_DHP, stat )
+    {
+        struct list_traits: public cc::iterable_list::traits
+        {
+            typedef cmp compare;
+            typedef cds::backoff::yield back_off;
+            typedef cc::iterable_list::stat<> stat;
+        };
+        typedef cc::IterableKVList< gc_type, key_type, value_type, list_traits > list_type;
+
+        struct map_traits: public cc::michael_map::traits
+        {
+            typedef hash1 hash;
+        };
+        typedef cc::MichaelHashMap< gc_type, list_type, map_traits > map_type;
+
+        map_type s( kSize, 8 );
+        test( s );
+    }
+
+    TEST_F( MichaelIterableMap_DHP, wrapped_stat )
+    {
+        struct list_traits: public cc::iterable_list::traits
+        {
+            typedef cmp compare;
+            typedef cc::iterable_list::wrapped_stat<> stat;
+        };
+        typedef cc::IterableKVList< gc_type, key_type, value_type, list_traits > list_type;
+
+        struct map_traits: public cc::michael_map::traits
+        {
+            typedef hash1 hash;
+        };
+        typedef cc::MichaelHashMap< gc_type, list_type, map_traits > map_type;
+
+        map_type s( kSize, 8 );
+        test( s );
+    }
+
+} // namespace
+
diff --git a/test/unit/map/michael_iterable_hp.cpp b/test/unit/map/michael_iterable_hp.cpp
new file mode 100644 (file)
index 0000000..1f0f033
--- /dev/null
@@ -0,0 +1,198 @@
+/*
+    This file is a part of libcds - Concurrent Data Structures library
+
+    (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016
+
+    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:
+
+    * Redistributions of source code must retain the above copyright notice, this
+      list of conditions and the following disclaimer.
+
+    * Redistributions in binary form must reproduce the above copyright notice,
+      this list of conditions and the following disclaimer in the documentation
+      and/or other materials provided with the distribution.
+
+    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+    AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+    IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+    DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+    FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+    DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+    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.
+*/
+
+#include "test_michael_iterable_hp.h"
+
+#include <cds/container/iterable_kvlist_hp.h>
+#include <cds/container/michael_map.h>
+
+namespace {
+
+    namespace cc = cds::container;
+    typedef cds::gc::HP gc_type;
+
+    class MichaelIterableMap_HP: public cds_test::michael_iterable_hp
+    {
+    protected:
+        typedef cds_test::michael_iterable_hp base_class;
+
+        void SetUp()
+        {
+            typedef cc::IterableKVList< gc_type, key_type, value_type > list_type;
+            typedef cc::MichaelHashMap< gc_type, list_type >   map_type;
+
+            // +3 - for guarded_ptr and iterator
+            cds::gc::hp::GarbageCollector::Construct( map_type::c_nHazardPtrCount + 3, 1, 16 );
+            cds::threading::Manager::attachThread();
+        }
+
+        void TearDown()
+        {
+            cds::threading::Manager::detachThread();
+            cds::gc::hp::GarbageCollector::Destruct( true );
+        }
+    };
+
+    TEST_F( MichaelIterableMap_HP, compare )
+    {
+        typedef cc::IterableKVList< gc_type, key_type, value_type,
+            typename cc::iterable_list::make_traits<
+                cds::opt::compare< cmp >
+            >::type
+        > list_type;
+
+        typedef cc::MichaelHashMap< gc_type, list_type, 
+            typename cc::michael_map::make_traits<
+                cds::opt::hash< hash1 >
+            >::type
+        > map_type;
+
+        map_type m( kSize, 2 );
+        test( m );
+    }
+
+    TEST_F( MichaelIterableMap_HP, less )
+    {
+        typedef cc::IterableKVList< gc_type, key_type, value_type,
+            typename cc::iterable_list::make_traits<
+                cds::opt::less< less >
+            >::type
+        > list_type;
+
+        typedef cc::MichaelHashMap< gc_type, list_type, 
+            typename cc::michael_map::make_traits<
+                cds::opt::hash< hash1 >
+            >::type
+        > map_type;
+
+        map_type m( kSize, 1 );
+        test( m );
+    }
+
+    TEST_F( MichaelIterableMap_HP, cmpmix )
+    {
+        typedef cc::IterableKVList< gc_type, key_type, value_type,
+            typename cc::iterable_list::make_traits<
+                cds::opt::less< less >
+                ,cds::opt::compare< cmp >
+            >::type
+        > list_type;
+
+        typedef cc::MichaelHashMap< gc_type, list_type, 
+            typename cc::michael_map::make_traits<
+                cds::opt::hash< hash1 >
+            >::type
+        > map_type;
+
+        map_type m( kSize, 2 );
+        test( m );
+    }
+
+    TEST_F( MichaelIterableMap_HP, backoff )
+    {
+        struct list_traits: public cc::iterable_list::traits
+        {
+            typedef cmp compare;
+            typedef cds::backoff::exponential<cds::backoff::pause, cds::backoff::yield> back_off;
+        };
+        typedef cc::IterableKVList< gc_type, key_type, value_type, list_traits > list_type;
+
+        struct map_traits: public cc::michael_map::traits
+        {
+            typedef hash1 hash;
+            typedef cds::atomicity::item_counter item_counter;
+        };
+        typedef cc::MichaelHashMap< gc_type, list_type, map_traits > map_type;
+
+        map_type m( kSize, 4 );
+        test( m );
+    }
+
+    TEST_F( MichaelIterableMap_HP, seq_cst )
+    {
+        struct list_traits: public cc::iterable_list::traits
+        {
+            typedef cmp compare;
+            typedef cds::backoff::yield back_off;
+            typedef cds::opt::v::sequential_consistent memory_model;
+        };
+        typedef cc::IterableKVList< gc_type, key_type, value_type, list_traits > list_type;
+
+        struct map_traits: public cc::michael_map::traits
+        {
+            typedef hash1 hash;
+        };
+        typedef cc::MichaelHashMap< gc_type, list_type, map_traits > map_type;
+
+        map_type s( kSize, 8 );
+        test( s );
+    }
+
+    TEST_F( MichaelIterableMap_HP, stat )
+    {
+        struct list_traits: public cc::iterable_list::traits
+        {
+            typedef cmp compare;
+            typedef cds::backoff::yield back_off;
+            typedef cc::iterable_list::stat<> stat;
+        };
+        typedef cc::IterableKVList< gc_type, key_type, value_type, list_traits > list_type;
+
+        struct map_traits: public cc::michael_map::traits
+        {
+            typedef hash1 hash;
+        };
+        typedef cc::MichaelHashMap< gc_type, list_type, map_traits > map_type;
+
+        map_type s( kSize, 8 );
+        test( s );
+    }
+
+    TEST_F( MichaelIterableMap_HP, wrapped_stat )
+    {
+        struct list_traits: public cc::iterable_list::traits
+        {
+            typedef cmp compare;
+            typedef cc::iterable_list::wrapped_stat<> stat;
+        };
+        typedef cc::IterableKVList< gc_type, key_type, value_type, list_traits > list_type;
+
+        struct map_traits: public cc::michael_map::traits
+        {
+            typedef hash1 hash;
+        };
+        typedef cc::MichaelHashMap< gc_type, list_type, map_traits > map_type;
+
+        map_type s( kSize, 8 );
+        test( s );
+    }
+
+} // namespace
+
index 02b535e8a7ebb9bd82820d2a86bbce1a2170ab84..27968f5c4498a7a9f4653cfb9d8370e8b3e912dd 100644 (file)
@@ -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.
 */
 
 #include "test_map_hp.h"
 */
 
 #include "test_map_hp.h"
@@ -174,5 +174,45 @@ namespace {
         test( m );
     }
 
         test( m );
     }
 
+    TEST_F( MichaelLazyMap_DHP, stat )
+    {
+        struct list_traits: public cc::lazy_list::traits
+        {
+            typedef cmp compare;
+            typedef cds::backoff::yield back_off;
+            typedef cc::lazy_list::stat<> stat;
+        };
+        typedef cc::LazyKVList< gc_type, key_type, value_type, list_traits > list_type;
+
+        struct map_traits: public cc::michael_map::traits
+        {
+            typedef hash1 hash;
+        };
+        typedef cc::MichaelHashMap< gc_type, list_type, map_traits > map_type;
+
+        map_type m( kSize, 2 );
+        test( m );
+    }
+
+    TEST_F( MichaelLazyMap_DHP, wrapped_stat )
+    {
+        struct list_traits: public cc::lazy_list::traits
+        {
+            typedef cmp compare;
+            typedef cds::backoff::yield back_off;
+            typedef cc::lazy_list::wrapped_stat<> stat;
+        };
+        typedef cc::LazyKVList< gc_type, key_type, value_type, list_traits > list_type;
+
+        struct map_traits: public cc::michael_map::traits
+        {
+            typedef hash1 hash;
+        };
+        typedef cc::MichaelHashMap< gc_type, list_type, map_traits > map_type;
+
+        map_type m( kSize, 2 );
+        test( m );
+    }
+
 } // namespace
 
 } // namespace
 
index 5376a2e871b61877983d086f61a348be8b1bac50..209fc27bb86f69886308da49a61d8c7ed4bba893 100644 (file)
@@ -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.
 */
 
 #include "test_map_hp.h"
 */
 
 #include "test_map_hp.h"
@@ -175,5 +175,45 @@ namespace {
         test( m );
     }
 
         test( m );
     }
 
+    TEST_F( MichaelLazyMap_HP, stat )
+    {
+        struct list_traits: public cc::lazy_list::traits
+        {
+            typedef cmp compare;
+            typedef cds::backoff::yield back_off;
+            typedef cc::lazy_list::stat<> stat;
+        };
+        typedef cc::LazyKVList< gc_type, key_type, value_type, list_traits > list_type;
+
+        struct map_traits: public cc::michael_map::traits
+        {
+            typedef hash1 hash;
+        };
+        typedef cc::MichaelHashMap< gc_type, list_type, map_traits > map_type;
+
+        map_type m( kSize, 2 );
+        test( m );
+    }
+
+    TEST_F( MichaelLazyMap_HP, wrapped_stat )
+    {
+        struct list_traits: public cc::lazy_list::traits
+        {
+            typedef cmp compare;
+            typedef cds::backoff::yield back_off;
+            typedef cc::lazy_list::wrapped_stat<> stat;
+        };
+        typedef cc::LazyKVList< gc_type, key_type, value_type, list_traits > list_type;
+
+        struct map_traits: public cc::michael_map::traits
+        {
+            typedef hash1 hash;
+        };
+        typedef cc::MichaelHashMap< gc_type, list_type, map_traits > map_type;
+
+        map_type m( kSize, 2 );
+        test( m );
+    }
+
 } // namespace
 
 } // namespace
 
index 94162358c3ca528b869f85353f3af53655d33aa5..a1cad613d63dbead013db0be5b37a131f359c295 100644 (file)
@@ -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.
 */
 
 #include "test_map_hp.h"
 */
 
 #include "test_map_hp.h"
@@ -154,5 +154,44 @@ namespace {
         test( s );
     }
 
         test( s );
     }
 
+    TEST_F( MichaelMap_DHP, stat )
+    {
+        struct list_traits: public cc::michael_list::traits
+        {
+            typedef cmp compare;
+            typedef cds::backoff::yield back_off;
+            typedef cc::michael_list::stat<> stat;
+        };
+        typedef cc::MichaelKVList< gc_type, key_type, value_type, list_traits > list_type;
+
+        struct map_traits: public cc::michael_map::traits
+        {
+            typedef hash1 hash;
+        };
+        typedef cc::MichaelHashMap< gc_type, list_type, map_traits > map_type;
+
+        map_type s( kSize, 8 );
+        test( s );
+    }
+
+    TEST_F( MichaelMap_DHP, wrapped_stat )
+    {
+        struct list_traits: public cc::michael_list::traits
+        {
+            typedef cmp compare;
+            typedef cc::michael_list::wrapped_stat<> stat;
+        };
+        typedef cc::MichaelKVList< gc_type, key_type, value_type, list_traits > list_type;
+
+        struct map_traits: public cc::michael_map::traits
+        {
+            typedef hash1 hash;
+        };
+        typedef cc::MichaelHashMap< gc_type, list_type, map_traits > map_type;
+
+        map_type s( kSize, 8 );
+        test( s );
+    }
+
 } // namespace
 
 } // namespace
 
index b69aa597745bc894237946c4f11381bc164037a1..6b48b7845f7e1d53d56ad37ae4de1b789e684bf0 100644 (file)
@@ -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.
 */
 
 #include "test_map_hp.h"
 */
 
 #include "test_map_hp.h"
@@ -155,5 +155,45 @@ namespace {
         test( s );
     }
 
         test( s );
     }
 
+    TEST_F( MichaelMap_HP, stat )
+    {
+        struct list_traits: public cc::michael_list::traits
+        {
+            typedef cmp compare;
+            typedef cds::backoff::yield back_off;
+            typedef cc::michael_list::stat<> stat;
+        };
+        typedef cc::MichaelKVList< gc_type, key_type, value_type, list_traits > list_type;
+
+        struct map_traits: public cc::michael_map::traits
+        {
+            typedef hash1 hash;
+        };
+        typedef cc::MichaelHashMap< gc_type, list_type, map_traits > map_type;
+
+        map_type s( kSize, 8 );
+        test( s );
+    }
+
+    TEST_F( MichaelMap_HP, wrapped_stat )
+    {
+        struct list_traits: public cc::michael_list::traits
+        {
+            typedef cmp compare;
+            typedef cds::backoff::yield back_off;
+            typedef cc::michael_list::wrapped_stat<> stat;
+        };
+        typedef cc::MichaelKVList< gc_type, key_type, value_type, list_traits > list_type;
+
+        struct map_traits: public cc::michael_map::traits
+        {
+            typedef hash1 hash;
+        };
+        typedef cc::MichaelHashMap< gc_type, list_type, map_traits > map_type;
+
+        map_type s( kSize, 8 );
+        test( s );
+    }
+
 } // namespace
 
 } // namespace
 
index 2c3912c213772e28601a9a5553cb8fec6abc7d28..5aee1d10ed2f78f08aa3e1ec03f8e7f2de9f475d 100644 (file)
@@ -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_MAP_TEST_MAP_H
 */
 
 #ifndef CDSUNIT_MAP_TEST_MAP_H
@@ -50,8 +50,8 @@ namespace cds_test {
             // Precondition: map is empty
             // Postcondition: map is empty
 
             // Precondition: map is empty
             // Postcondition: map is empty
 
-            ASSERT_TRUE( m.empty());
-            ASSERT_CONTAINER_SIZE( m, 0 );
+            EXPECT_TRUE( m.empty());
+            EXPECT_CONTAINER_SIZE( m, 0 );
 
             typedef typename Map::value_type map_pair;
             size_t const kkSize = kSize;
 
             typedef typename Map::value_type map_pair;
             size_t const kkSize = kSize;
@@ -73,16 +73,16 @@ namespace cds_test {
             for ( auto const& i : arrKeys ) {
                 value_type const& val( arrVals.at( i.nKey ));
 
             for ( auto const& i : arrKeys ) {
                 value_type const& val( arrVals.at( i.nKey ));
 
-                ASSERT_FALSE( m.contains( i.nKey ));
-                ASSERT_FALSE( m.contains( i ));
-                ASSERT_FALSE( m.contains( other_item( i.nKey ), other_less()));
-                ASSERT_FALSE( m.find( i, []( map_pair const& ) {
-                    ASSERT_TRUE( false );
+                EXPECT_FALSE( m.contains( i.nKey ));
+                EXPECT_FALSE( m.contains( i ));
+                EXPECT_FALSE( m.contains( other_item( i.nKey ), other_less()));
+                EXPECT_FALSE( m.find( i, []( map_pair const& ) {
+                    EXPECT_TRUE( false );
                 } ));
                 } ));
-                ASSERT_FALSE( m.find( i.nKey, []( map_pair const& ) {
+                EXPECT_FALSE( m.find( i.nKey, []( map_pair const& ) {
                     EXPECT_TRUE( false );
                 } ));
                     EXPECT_TRUE( false );
                 } ));
-                ASSERT_FALSE( m.find_with( other_item( i.nKey ), other_less(), []( map_pair const& ) {
+                EXPECT_FALSE( m.find_with( other_item( i.nKey ), other_less(), []( map_pair const& ) {
                     EXPECT_TRUE( false );
                 } ));
 
                     EXPECT_TRUE( false );
                 } ));
 
@@ -90,65 +90,65 @@ namespace cds_test {
 
                 switch ( i.nKey % 16 ) {
                 case 0:
 
                 switch ( i.nKey % 16 ) {
                 case 0:
-                    ASSERT_TRUE( m.insert( i ));
-                    ASSERT_FALSE( m.insert( i ));
-                    ASSERT_TRUE( m.find( i.nKey, []( map_pair& v ) {
+                    EXPECT_TRUE( m.insert( i ));
+                    EXPECT_FALSE( m.insert( i ));
+                    EXPECT_TRUE( m.find( i.nKey, []( map_pair& v ) {
                         v.second.nVal = v.first.nKey;
                         v.second.strVal = std::to_string( v.first.nKey );
                     } ));
                     break;
                 case 1:
                         v.second.nVal = v.first.nKey;
                         v.second.strVal = std::to_string( v.first.nKey );
                     } ));
                     break;
                 case 1:
-                    ASSERT_TRUE( m.insert( i.nKey ));
-                    ASSERT_FALSE( m.insert( i.nKey ));
-                    ASSERT_TRUE( m.find( i.nKey, []( map_pair& v ) {
+                    EXPECT_TRUE( m.insert( i.nKey ));
+                    EXPECT_FALSE( m.insert( i.nKey ));
+                    EXPECT_TRUE( m.find( i.nKey, []( map_pair& v ) {
                         v.second.nVal = v.first.nKey;
                         v.second.strVal = std::to_string( v.first.nKey );
                     } ));
                     break;
                 case 2:
                         v.second.nVal = v.first.nKey;
                         v.second.strVal = std::to_string( v.first.nKey );
                     } ));
                     break;
                 case 2:
-                    ASSERT_TRUE( m.insert( std::to_string( i.nKey )));
-                    ASSERT_FALSE( m.insert( std::to_string( i.nKey )));
-                    ASSERT_TRUE( m.find( i.nKey, []( map_pair& v ) {
+                    EXPECT_TRUE( m.insert( std::to_string( i.nKey )));
+                    EXPECT_FALSE( m.insert( std::to_string( i.nKey )));
+                    EXPECT_TRUE( m.find( i.nKey, []( map_pair& v ) {
                         v.second.nVal = v.first.nKey;
                         v.second.strVal = std::to_string( v.first.nKey );
                     } ));
                     break;
                 case 3:
                         v.second.nVal = v.first.nKey;
                         v.second.strVal = std::to_string( v.first.nKey );
                     } ));
                     break;
                 case 3:
-                    ASSERT_TRUE( m.insert( i, val ));
-                    ASSERT_FALSE( m.insert( i, val ));
+                    EXPECT_TRUE( m.insert( i, val ));
+                    EXPECT_FALSE( m.insert( i, val ));
                     break;
                 case 4:
                     break;
                 case 4:
-                    ASSERT_TRUE( m.insert( i.nKey, val.strVal ));
-                    ASSERT_FALSE( m.insert( i.nKey, val.strVal ));
+                    EXPECT_TRUE( m.insert( i.nKey, val.strVal ));
+                    EXPECT_FALSE( m.insert( i.nKey, val.strVal ));
                     break;
                 case 5:
                     break;
                 case 5:
-                    ASSERT_TRUE( m.insert( val.strVal, i.nKey ));
-                    ASSERT_FALSE( m.insert( val.strVal, i.nKey ));
+                    EXPECT_TRUE( m.insert( val.strVal, i.nKey ));
+                    EXPECT_FALSE( m.insert( val.strVal, i.nKey ));
                     break;
                 case 6:
                     break;
                 case 6:
-                    ASSERT_TRUE( m.insert_with( i, []( map_pair& v ) {
+                    EXPECT_TRUE( m.insert_with( i, []( map_pair& v ) {
                         v.second.nVal = v.first.nKey;
                         v.second.strVal = std::to_string( v.first.nKey );
                     } ));
                         v.second.nVal = v.first.nKey;
                         v.second.strVal = std::to_string( v.first.nKey );
                     } ));
-                    ASSERT_FALSE( m.insert_with( i, []( map_pair& v ) {
+                    EXPECT_FALSE( m.insert_with( i, []( map_pair& v ) {
                         EXPECT_TRUE( false );
                     } ));
                     break;
                 case 7:
                         EXPECT_TRUE( false );
                     } ));
                     break;
                 case 7:
-                    ASSERT_TRUE( m.insert_with( i.nKey, []( map_pair& v ) {
+                    EXPECT_TRUE( m.insert_with( i.nKey, []( map_pair& v ) {
                         v.second.nVal = v.first.nKey;
                         v.second.strVal = std::to_string( v.first.nKey );
                     } ));
                         v.second.nVal = v.first.nKey;
                         v.second.strVal = std::to_string( v.first.nKey );
                     } ));
-                    ASSERT_FALSE( m.insert_with( i.nKey, []( map_pair& v ) {
+                    EXPECT_FALSE( m.insert_with( i.nKey, []( map_pair& v ) {
                         EXPECT_TRUE( false );
                     } ));
                     break;
                 case 8:
                         EXPECT_TRUE( false );
                     } ));
                     break;
                 case 8:
-                    ASSERT_TRUE( m.insert_with( val.strVal, []( map_pair& v ) {
+                    EXPECT_TRUE( m.insert_with( val.strVal, []( map_pair& v ) {
                         v.second.nVal = v.first.nKey;
                         v.second.strVal = std::to_string( v.first.nKey );
                     } ));
                         v.second.nVal = v.first.nKey;
                         v.second.strVal = std::to_string( v.first.nKey );
                     } ));
-                    ASSERT_FALSE( m.insert_with( val.strVal, []( map_pair& v ) {
+                    EXPECT_FALSE( m.insert_with( val.strVal, []( map_pair& v ) {
                         EXPECT_TRUE( false );
                     } ));
                     break;
                         EXPECT_TRUE( false );
                     } ));
                     break;
@@ -156,122 +156,122 @@ namespace cds_test {
                     updResult = m.update( i.nKey, []( bool, map_pair& ) {
                         EXPECT_TRUE( false );
                     }, false );
                     updResult = m.update( i.nKey, []( bool, map_pair& ) {
                         EXPECT_TRUE( false );
                     }, false );
-                    ASSERT_FALSE( updResult.first );
-                    ASSERT_FALSE( updResult.second );
+                    EXPECT_FALSE( updResult.first );
+                    EXPECT_FALSE( updResult.second );
 
                     updResult = m.update( i.nKey, []( bool bNew, map_pair& v ) {
                         EXPECT_TRUE( bNew );
                         v.second.nVal = v.first.nKey;
                     });
 
                     updResult = m.update( i.nKey, []( bool bNew, map_pair& v ) {
                         EXPECT_TRUE( bNew );
                         v.second.nVal = v.first.nKey;
                     });
-                    ASSERT_TRUE( updResult.first );
-                    ASSERT_TRUE( updResult.second );
+                    EXPECT_TRUE( updResult.first );
+                    EXPECT_TRUE( updResult.second );
 
                     updResult = m.update( i.nKey, []( bool bNew, map_pair& v ) {
                         EXPECT_FALSE( bNew );
                         EXPECT_EQ( v.first.nKey, v.second.nVal );
                         v.second.strVal = std::to_string( v.second.nVal );
                     } );
 
                     updResult = m.update( i.nKey, []( bool bNew, map_pair& v ) {
                         EXPECT_FALSE( bNew );
                         EXPECT_EQ( v.first.nKey, v.second.nVal );
                         v.second.strVal = std::to_string( v.second.nVal );
                     } );
-                    ASSERT_TRUE( updResult.first );
-                    ASSERT_FALSE( updResult.second );
+                    EXPECT_TRUE( updResult.first );
+                    EXPECT_FALSE( updResult.second );
                     break;
                 case 10:
                     updResult = m.update( i, []( bool, map_pair& ) {
                         EXPECT_TRUE( false );
                     }, false );
                     break;
                 case 10:
                     updResult = m.update( i, []( bool, map_pair& ) {
                         EXPECT_TRUE( false );
                     }, false );
-                    ASSERT_FALSE( updResult.first );
-                    ASSERT_FALSE( updResult.second );
+                    EXPECT_FALSE( updResult.first );
+                    EXPECT_FALSE( updResult.second );
 
                     updResult = m.update( i, []( bool bNew, map_pair& v ) {
                         EXPECT_TRUE( bNew );
                         v.second.nVal = v.first.nKey;
                     });
 
                     updResult = m.update( i, []( bool bNew, map_pair& v ) {
                         EXPECT_TRUE( bNew );
                         v.second.nVal = v.first.nKey;
                     });
-                    ASSERT_TRUE( updResult.first );
-                    ASSERT_TRUE( updResult.second );
+                    EXPECT_TRUE( updResult.first );
+                    EXPECT_TRUE( updResult.second );
 
                     updResult = m.update( i, []( bool bNew, map_pair& v ) {
                         EXPECT_FALSE( bNew );
                         EXPECT_EQ( v.first.nKey, v.second.nVal );
                         v.second.strVal = std::to_string( v.second.nVal );
                     } );
 
                     updResult = m.update( i, []( bool bNew, map_pair& v ) {
                         EXPECT_FALSE( bNew );
                         EXPECT_EQ( v.first.nKey, v.second.nVal );
                         v.second.strVal = std::to_string( v.second.nVal );
                     } );
-                    ASSERT_TRUE( updResult.first );
-                    ASSERT_FALSE( updResult.second );
+                    EXPECT_TRUE( updResult.first );
+                    EXPECT_FALSE( updResult.second );
                     break;
                 case 11:
                     updResult = m.update( val.strVal, []( bool, map_pair& ) {
                         EXPECT_TRUE( false );
                     }, false );
                     break;
                 case 11:
                     updResult = m.update( val.strVal, []( bool, map_pair& ) {
                         EXPECT_TRUE( false );
                     }, false );
-                    ASSERT_FALSE( updResult.first );
-                    ASSERT_FALSE( updResult.second );
+                    EXPECT_FALSE( updResult.first );
+                    EXPECT_FALSE( updResult.second );
 
                     updResult = m.update( val.strVal, []( bool bNew, map_pair& v ) {
                         EXPECT_TRUE( bNew );
                         v.second.nVal = v.first.nKey;
                     });
 
                     updResult = m.update( val.strVal, []( bool bNew, map_pair& v ) {
                         EXPECT_TRUE( bNew );
                         v.second.nVal = v.first.nKey;
                     });
-                    ASSERT_TRUE( updResult.first );
-                    ASSERT_TRUE( updResult.second );
+                    EXPECT_TRUE( updResult.first );
+                    EXPECT_TRUE( updResult.second );
 
                     updResult = m.update( val.strVal, []( bool bNew, map_pair& v ) {
                         EXPECT_FALSE( bNew );
                         EXPECT_EQ( v.first.nKey, v.second.nVal );
                         v.second.strVal = std::to_string( v.second.nVal );
                     } );
 
                     updResult = m.update( val.strVal, []( bool bNew, map_pair& v ) {
                         EXPECT_FALSE( bNew );
                         EXPECT_EQ( v.first.nKey, v.second.nVal );
                         v.second.strVal = std::to_string( v.second.nVal );
                     } );
-                    ASSERT_TRUE( updResult.first );
-                    ASSERT_FALSE( updResult.second );
+                    EXPECT_TRUE( updResult.first );
+                    EXPECT_FALSE( updResult.second );
                     break;
                 case 12:
                     break;
                 case 12:
-                    ASSERT_TRUE( m.emplace( i.nKey ));
-                    ASSERT_FALSE( m.emplace( i.nKey ));
-                    ASSERT_TRUE( m.find( i.nKey, []( map_pair& v ) {
+                    EXPECT_TRUE( m.emplace( i.nKey ));
+                    EXPECT_FALSE( m.emplace( i.nKey ));
+                    EXPECT_TRUE( m.find( i.nKey, []( map_pair& v ) {
                         v.second.nVal = v.first.nKey;
                         v.second.strVal = std::to_string( v.first.nKey );
                     } ));
                     break;
                 case 13:
                         v.second.nVal = v.first.nKey;
                         v.second.strVal = std::to_string( v.first.nKey );
                     } ));
                     break;
                 case 13:
-                    ASSERT_TRUE( m.emplace( i, i.nKey ));
-                    ASSERT_FALSE( m.emplace( i, i.nKey ));
+                    EXPECT_TRUE( m.emplace( i, i.nKey ));
+                    EXPECT_FALSE( m.emplace( i, i.nKey ));
                     break;
                 case 14:
                     {
                         std::string str = val.strVal;
                     break;
                 case 14:
                     {
                         std::string str = val.strVal;
-                        ASSERT_TRUE( m.emplace( i, std::move( str )));
-                        ASSERT_TRUE( str.empty());
+                        EXPECT_TRUE( m.emplace( i, std::move( str )));
+                        EXPECT_TRUE( str.empty());
                         str = val.strVal;
                         str = val.strVal;
-                        ASSERT_FALSE( m.emplace( i, std::move( str )));
-                        ASSERT_TRUE( str.empty());
+                        EXPECT_FALSE( m.emplace( i, std::move( str )));
+                        EXPECT_TRUE( str.empty());
                     }
                     break;
                 case 15:
                     {
                         std::string str = val.strVal;
                     }
                     break;
                 case 15:
                     {
                         std::string str = val.strVal;
-                        ASSERT_TRUE( m.emplace( i, i.nKey, std::move( str )));
-                        ASSERT_TRUE( str.empty());
+                        EXPECT_TRUE( m.emplace( i, i.nKey, std::move( str )));
+                        EXPECT_TRUE( str.empty());
                         str = val.strVal;
                         str = val.strVal;
-                        ASSERT_FALSE( m.emplace( i, i.nKey, std::move( str )));
-                        ASSERT_TRUE( str.empty());
+                        EXPECT_FALSE( m.emplace( i, i.nKey, std::move( str )));
+                        EXPECT_TRUE( str.empty());
                     }
                     break;
                 }
 
                     }
                     break;
                 }
 
-                ASSERT_TRUE( m.contains( i.nKey ));
-                ASSERT_TRUE( m.contains( i ));
-                ASSERT_TRUE( m.contains( other_item( i.nKey ), other_less()));
-                ASSERT_TRUE( m.find( i, []( map_pair const& v ) {
+                EXPECT_TRUE( m.contains( i.nKey ));
+                EXPECT_TRUE( m.contains( i ));
+                EXPECT_TRUE( m.contains( other_item( i.nKey ), other_less()));
+                EXPECT_TRUE( m.find( i, []( map_pair const& v ) {
                     EXPECT_EQ( v.first.nKey, v.second.nVal );
                     EXPECT_EQ( std::to_string( v.first.nKey ), v.second.strVal );
                 } ));
                     EXPECT_EQ( v.first.nKey, v.second.nVal );
                     EXPECT_EQ( std::to_string( v.first.nKey ), v.second.strVal );
                 } ));
-                ASSERT_TRUE( m.find( i.nKey, []( map_pair const& v ) {
+                EXPECT_TRUE( m.find( i.nKey, []( map_pair const& v ) {
                     EXPECT_EQ( v.first.nKey, v.second.nVal );
                     EXPECT_EQ( std::to_string( v.first.nKey ), v.second.strVal );
                 } ));
                     EXPECT_EQ( v.first.nKey, v.second.nVal );
                     EXPECT_EQ( std::to_string( v.first.nKey ), v.second.strVal );
                 } ));
-                ASSERT_TRUE( m.find_with( other_item( i.nKey ), other_less(), []( map_pair const& v ) {
+                EXPECT_TRUE( m.find_with( other_item( i.nKey ), other_less(), []( map_pair const& v ) {
                     EXPECT_EQ( v.first.nKey, v.second.nVal );
                     EXPECT_EQ( std::to_string( v.first.nKey ), v.second.strVal );
                 } ));
             }
                     EXPECT_EQ( v.first.nKey, v.second.nVal );
                     EXPECT_EQ( std::to_string( v.first.nKey ), v.second.strVal );
                 } ));
             }
-            ASSERT_FALSE( m.empty() );
-            ASSERT_CONTAINER_SIZE( m, kkSize );
-            ASSERT_FALSE( m.begin() == m.end() );
-            ASSERT_FALSE( m.cbegin() == m.cend() );
+            EXPECT_FALSE( m.empty() );
+            EXPECT_CONTAINER_SIZE( m, kkSize );
+            EXPECT_FALSE( m.begin() == m.end() );
+            EXPECT_FALSE( m.cbegin() == m.cend() );
 
             shuffle( arrKeys.begin(), arrKeys.end() );
 
 
             shuffle( arrKeys.begin(), arrKeys.end() );
 
@@ -279,19 +279,19 @@ namespace cds_test {
             for ( auto const& i : arrKeys ) {
                 value_type const& val( arrVals.at( i.nKey ) );
 
             for ( auto const& i : arrKeys ) {
                 value_type const& val( arrVals.at( i.nKey ) );
 
-                ASSERT_TRUE( m.contains( i.nKey ));
-                ASSERT_TRUE( m.contains( val.strVal ) );
-                ASSERT_TRUE( m.contains( i ));
-                ASSERT_TRUE( m.contains( other_item( i.nKey ), other_less()));
-                ASSERT_TRUE( m.find( i, []( map_pair const& v ) {
+                EXPECT_TRUE( m.contains( i.nKey ));
+                EXPECT_TRUE( m.contains( val.strVal ) );
+                EXPECT_TRUE( m.contains( i ));
+                EXPECT_TRUE( m.contains( other_item( i.nKey ), other_less()));
+                EXPECT_TRUE( m.find( i, []( map_pair const& v ) {
                     EXPECT_EQ( v.first.nKey, v.second.nVal );
                     EXPECT_EQ( std::to_string( v.first.nKey ), v.second.strVal );
                 } ));
                     EXPECT_EQ( v.first.nKey, v.second.nVal );
                     EXPECT_EQ( std::to_string( v.first.nKey ), v.second.strVal );
                 } ));
-                ASSERT_TRUE( m.find( i.nKey, []( map_pair const& v ) {
+                EXPECT_TRUE( m.find( i.nKey, []( map_pair const& v ) {
                     EXPECT_EQ( v.first.nKey, v.second.nVal );
                     EXPECT_EQ( std::to_string( v.first.nKey ), v.second.strVal );
                 } ));
                     EXPECT_EQ( v.first.nKey, v.second.nVal );
                     EXPECT_EQ( std::to_string( v.first.nKey ), v.second.strVal );
                 } ));
-                ASSERT_TRUE( m.find_with( other_item( i.nKey ), other_less(), []( map_pair const& v ) {
+                EXPECT_TRUE( m.find_with( other_item( i.nKey ), other_less(), []( map_pair const& v ) {
                     EXPECT_EQ( v.first.nKey, v.second.nVal );
                     EXPECT_EQ( std::to_string( v.first.nKey ), v.second.strVal );
                 } ));
                     EXPECT_EQ( v.first.nKey, v.second.nVal );
                     EXPECT_EQ( std::to_string( v.first.nKey ), v.second.strVal );
                 } ));
@@ -299,90 +299,90 @@ namespace cds_test {
 
                 switch ( i.nKey % 8 ) {
                 case 0:
 
                 switch ( i.nKey % 8 ) {
                 case 0:
-                    ASSERT_TRUE( m.erase( i ));
-                    ASSERT_FALSE( m.erase( i ));
+                    EXPECT_TRUE( m.erase( i ));
+                    EXPECT_FALSE( m.erase( i ));
                     break;
                 case 1:
                     break;
                 case 1:
-                    ASSERT_TRUE( m.erase( i.nKey ));
-                    ASSERT_FALSE( m.erase( i.nKey ));
+                    EXPECT_TRUE( m.erase( i.nKey ));
+                    EXPECT_FALSE( m.erase( i.nKey ));
                     break;
                 case 2:
                     break;
                 case 2:
-                    ASSERT_TRUE( m.erase( val.strVal ));
-                    ASSERT_FALSE( m.erase( val.strVal ));
+                    EXPECT_TRUE( m.erase( val.strVal ));
+                    EXPECT_FALSE( m.erase( val.strVal ));
                     break;
                 case 3:
                     break;
                 case 3:
-                    ASSERT_TRUE( m.erase_with( other_item( i.nKey ), other_less()));
-                    ASSERT_FALSE( m.erase_with( other_item( i.nKey ), other_less()));
+                    EXPECT_TRUE( m.erase_with( other_item( i.nKey ), other_less()));
+                    EXPECT_FALSE( m.erase_with( other_item( i.nKey ), other_less()));
                     break;
                 case 4:
                     break;
                 case 4:
-                    ASSERT_TRUE( m.erase( i, []( map_pair& v ) {
+                    EXPECT_TRUE( m.erase( i, []( map_pair& v ) {
                         EXPECT_EQ( v.first.nKey, v.second.nVal );
                         EXPECT_EQ( std::to_string( v.first.nKey ), v.second.strVal );
                     }));
                         EXPECT_EQ( v.first.nKey, v.second.nVal );
                         EXPECT_EQ( std::to_string( v.first.nKey ), v.second.strVal );
                     }));
-                    ASSERT_FALSE( m.erase( i, []( map_pair& ) {
+                    EXPECT_FALSE( m.erase( i, []( map_pair& ) {
                         EXPECT_TRUE( false );
                     }));
                     break;
                 case 5:
                         EXPECT_TRUE( false );
                     }));
                     break;
                 case 5:
-                    ASSERT_TRUE( m.erase( i.nKey, []( map_pair& v ) {
+                    EXPECT_TRUE( m.erase( i.nKey, []( map_pair& v ) {
                         EXPECT_EQ( v.first.nKey, v.second.nVal );
                         EXPECT_EQ( std::to_string( v.first.nKey ), v.second.strVal );
                     }));
                         EXPECT_EQ( v.first.nKey, v.second.nVal );
                         EXPECT_EQ( std::to_string( v.first.nKey ), v.second.strVal );
                     }));
-                    ASSERT_FALSE( m.erase( i.nKey, []( map_pair& ) {
+                    EXPECT_FALSE( m.erase( i.nKey, []( map_pair& ) {
                         EXPECT_TRUE( false );
                     }));
                     break;
                 case 6:
                         EXPECT_TRUE( false );
                     }));
                     break;
                 case 6:
-                    ASSERT_TRUE( m.erase( val.strVal, []( map_pair& v ) {
+                    EXPECT_TRUE( m.erase( val.strVal, []( map_pair& v ) {
                         EXPECT_EQ( v.first.nKey, v.second.nVal );
                         EXPECT_EQ( std::to_string( v.first.nKey ), v.second.strVal );
                     }));
                         EXPECT_EQ( v.first.nKey, v.second.nVal );
                         EXPECT_EQ( std::to_string( v.first.nKey ), v.second.strVal );
                     }));
-                    ASSERT_FALSE( m.erase( val.strVal, []( map_pair& ) {
+                    EXPECT_FALSE( m.erase( val.strVal, []( map_pair& ) {
                         EXPECT_TRUE( false );
                     }));
                     break;
                 case 7:
                         EXPECT_TRUE( false );
                     }));
                     break;
                 case 7:
-                    ASSERT_TRUE( m.erase_with( other_item( i.nKey ), other_less(), []( map_pair& v ) {
+                    EXPECT_TRUE( m.erase_with( other_item( i.nKey ), other_less(), []( map_pair& v ) {
                         EXPECT_EQ( v.first.nKey, v.second.nVal );
                         EXPECT_EQ( std::to_string( v.first.nKey ), v.second.strVal );
                     }));
                         EXPECT_EQ( v.first.nKey, v.second.nVal );
                         EXPECT_EQ( std::to_string( v.first.nKey ), v.second.strVal );
                     }));
-                    ASSERT_FALSE( m.erase_with( other_item( i.nKey ), other_less(), []( map_pair& ) {
+                    EXPECT_FALSE( m.erase_with( other_item( i.nKey ), other_less(), []( map_pair& ) {
                         EXPECT_TRUE( false );
                     }));
                     break;
                 }
 
                         EXPECT_TRUE( false );
                     }));
                     break;
                 }
 
-                ASSERT_FALSE( m.contains( i.nKey ));
-                ASSERT_FALSE( m.contains( i ));
-                ASSERT_FALSE( m.contains( val.strVal ));
-                ASSERT_FALSE( m.contains( other_item( i.nKey ), other_less()));
-                ASSERT_FALSE( m.find( i, []( map_pair const& ) {
-                    ASSERT_TRUE( false );
+                EXPECT_FALSE( m.contains( i.nKey ));
+                EXPECT_FALSE( m.contains( i ));
+                EXPECT_FALSE( m.contains( val.strVal ));
+                EXPECT_FALSE( m.contains( other_item( i.nKey ), other_less()));
+                EXPECT_FALSE( m.find( i, []( map_pair const& ) {
+                    EXPECT_TRUE( false );
                 } ));
                 } ));
-                ASSERT_FALSE( m.find( i.nKey, []( map_pair const& ) {
+                EXPECT_FALSE( m.find( i.nKey, []( map_pair const& ) {
                     EXPECT_TRUE( false );
                 } ));
                     EXPECT_TRUE( false );
                 } ));
-                ASSERT_FALSE( m.find_with( other_item( i.nKey ), other_less(), []( map_pair const& ) {
+                EXPECT_FALSE( m.find_with( other_item( i.nKey ), other_less(), []( map_pair const& ) {
                     EXPECT_TRUE( false );
                 } ));
             }
                     EXPECT_TRUE( false );
                 } ));
             }
-            ASSERT_TRUE( m.empty() );
-            ASSERT_CONTAINER_SIZE( m, 0 );
+            EXPECT_TRUE( m.empty() );
+            EXPECT_CONTAINER_SIZE( m, 0 );
 
 
-            ASSERT_TRUE( m.begin() == m.end());
-            ASSERT_TRUE( m.cbegin() == m.cend());
+            EXPECT_TRUE( m.begin() == m.end());
+            EXPECT_TRUE( m.cbegin() == m.cend());
 
             // clear
             for ( auto const& i : arrKeys )
 
             // clear
             for ( auto const& i : arrKeys )
-                ASSERT_TRUE( m.insert( i ));
+                EXPECT_TRUE( m.insert( i ));
 
 
-            ASSERT_FALSE( m.empty() );
-            ASSERT_CONTAINER_SIZE( m, kkSize );
+            EXPECT_FALSE( m.empty() );
+            EXPECT_CONTAINER_SIZE( m, kkSize );
 
             m.clear();
 
 
             m.clear();
 
-            ASSERT_TRUE( m.empty() );
-            ASSERT_CONTAINER_SIZE( m, 0 );
+            EXPECT_TRUE( m.empty() );
+            EXPECT_CONTAINER_SIZE( m, 0 );
         }
     };
 
         }
     };
 
index 220951150c6d560ae261d3de49baa5d5f58587dd..d3305706029c61567b7c6954a0a1a07eed866a5d 100644 (file)
@@ -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_MAP_TEST_MAP_HP_H
 */
 
 #ifndef CDSUNIT_MAP_TEST_MAP_HP_H
@@ -48,8 +48,8 @@ namespace cds_test {
 
             base_class::test( m );
 
 
             base_class::test( m );
 
-            ASSERT_TRUE( m.empty());
-            ASSERT_CONTAINER_SIZE( m, 0 );
+            EXPECT_TRUE( m.empty());
+            EXPECT_CONTAINER_SIZE( m, 0 );
 
             typedef typename Map::value_type map_pair;
             size_t const kkSize = base_class::kSize;
 
             typedef typename Map::value_type map_pair;
             size_t const kkSize = base_class::kSize;
@@ -68,9 +68,9 @@ namespace cds_test {
             }
 
             for ( auto const& i : arrKeys )
             }
 
             for ( auto const& i : arrKeys )
-                ASSERT_TRUE( m.insert( i ) );
-            ASSERT_FALSE( m.empty() );
-            ASSERT_CONTAINER_SIZE( m, kkSize );
+                EXPECT_TRUE( m.insert( i ) );
+            EXPECT_FALSE( m.empty() );
+            EXPECT_CONTAINER_SIZE( m, kkSize );
 
             // iterators
             size_t nCount = 0;
 
             // iterators
             size_t nCount = 0;
@@ -97,15 +97,15 @@ namespace cds_test {
 
                 gp = m.get( i.nKey );
                 ASSERT_FALSE( !gp );
 
                 gp = m.get( i.nKey );
                 ASSERT_FALSE( !gp );
-                ASSERT_EQ( gp->first.nKey, i.nKey );
+                EXPECT_EQ( gp->first.nKey, i.nKey );
                 gp.release();
                 gp = m.get( i );
                 ASSERT_FALSE( !gp );
                 gp.release();
                 gp = m.get( i );
                 ASSERT_FALSE( !gp );
-                ASSERT_EQ( gp->first.nKey, i.nKey );
+                EXPECT_EQ( gp->first.nKey, i.nKey );
                 gp.release();
                 gp = m.get_with( other_item( i.nKey ), other_less());
                 ASSERT_FALSE( !gp );
                 gp.release();
                 gp = m.get_with( other_item( i.nKey ), other_less());
                 ASSERT_FALSE( !gp );
-                ASSERT_EQ( gp->first.nKey, i.nKey );
+                EXPECT_EQ( gp->first.nKey, i.nKey );
 
                 switch ( i.nKey % 4 ) {
                 case 0:
 
                 switch ( i.nKey % 4 ) {
                 case 0:
@@ -122,7 +122,7 @@ namespace cds_test {
                     break;
                 }
                 ASSERT_FALSE( !gp );
                     break;
                 }
                 ASSERT_FALSE( !gp );
-                ASSERT_EQ( gp->first.nKey, i.nKey );
+                EXPECT_EQ( gp->first.nKey, i.nKey );
                 gp.release();
 
                 gp = m.get( i.nKey );
                 gp.release();
 
                 gp = m.get( i.nKey );
@@ -132,8 +132,8 @@ namespace cds_test {
                 gp = m.get_with( other_item( i.nKey ), other_less() );
                 ASSERT_TRUE( !gp );
             }
                 gp = m.get_with( other_item( i.nKey ), other_less() );
                 ASSERT_TRUE( !gp );
             }
-            ASSERT_TRUE( m.empty() );
-            ASSERT_CONTAINER_SIZE( m, 0 );
+            EXPECT_TRUE( m.empty() );
+            EXPECT_CONTAINER_SIZE( m, 0 );
         }
     };
 
         }
     };
 
diff --git a/test/unit/map/test_michael_iterable.h b/test/unit/map/test_michael_iterable.h
new file mode 100644 (file)
index 0000000..54e2286
--- /dev/null
@@ -0,0 +1,411 @@
+/*
+    This file is a part of libcds - Concurrent Data Structures library
+
+    (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016
+
+    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:
+
+    * Redistributions of source code must retain the above copyright notice, this
+      list of conditions and the following disclaimer.
+
+    * Redistributions in binary form must reproduce the above copyright notice,
+      this list of conditions and the following disclaimer in the documentation
+      and/or other materials provided with the distribution.
+
+    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+    AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+    IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+    DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+    FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+    DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+    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.
+*/
+
+#ifndef CDSUNIT_MAP_TEST_MICHAEL_ITERABLE_MAP_H
+#define CDSUNIT_MAP_TEST_MICHAEL_ITERABLE_MAP_H
+
+#include "test_map_data.h"
+
+// forward declaration
+namespace cds { namespace container {} }
+
+namespace cds_test {
+
+    class michael_iterable_map: public map_fixture
+    {
+    public:
+        static size_t const kSize = 1000;
+
+    protected:
+        template <class Map>
+        void test( Map& m )
+        {
+            // Precondition: map is empty
+            // Postcondition: map is empty
+
+            EXPECT_TRUE( m.empty());
+            EXPECT_CONTAINER_SIZE( m, 0 );
+
+            typedef typename Map::value_type map_pair;
+            size_t const kkSize = kSize;
+
+            std::vector<key_type> arrKeys;
+            for ( int i = 0; i < static_cast<int>(kkSize); ++i )
+                arrKeys.push_back( key_type( i ));
+            shuffle( arrKeys.begin(), arrKeys.end());
+
+            std::vector< value_type > arrVals;
+            for ( size_t i = 0; i < kkSize; ++i ) {
+                value_type val;
+                val.nVal = static_cast<int>( i );
+                val.strVal = std::to_string( i );
+                arrVals.push_back( val );
+            }
+
+            // insert/find
+            for ( auto const& i : arrKeys ) {
+                value_type const& val( arrVals.at( i.nKey ));
+
+                EXPECT_FALSE( m.contains( i.nKey ));
+                EXPECT_FALSE( m.contains( i ));
+                EXPECT_FALSE( m.contains( other_item( i.nKey ), other_less()));
+                EXPECT_FALSE( m.find( i, []( map_pair const& ) {
+                    EXPECT_TRUE( false );
+                } ));
+                EXPECT_FALSE( m.find( i.nKey, []( map_pair const& ) {
+                    EXPECT_TRUE( false );
+                } ));
+                EXPECT_FALSE( m.find_with( other_item( i.nKey ), other_less(), []( map_pair const& ) {
+                    EXPECT_TRUE( false );
+                } ));
+
+                std::pair< bool, bool > updResult;
+
+                switch ( i.nKey % 17 ) {
+                case 0:
+                    EXPECT_TRUE( m.insert( i ));
+                    EXPECT_FALSE( m.insert( i ));
+                    EXPECT_TRUE( m.find( i.nKey, []( map_pair& v ) {
+                        v.second.nVal = v.first.nKey;
+                        v.second.strVal = std::to_string( v.first.nKey );
+                    } ));
+                    break;
+                case 1:
+                    EXPECT_TRUE( m.insert( i.nKey ));
+                    EXPECT_FALSE( m.insert( i.nKey ));
+                    EXPECT_TRUE( m.find( i.nKey, []( map_pair& v ) {
+                        v.second.nVal = v.first.nKey;
+                        v.second.strVal = std::to_string( v.first.nKey );
+                    } ));
+                    break;
+                case 2:
+                    EXPECT_TRUE( m.insert( std::to_string( i.nKey )));
+                    EXPECT_FALSE( m.insert( std::to_string( i.nKey )));
+                    EXPECT_TRUE( m.find( i.nKey, []( map_pair& v ) {
+                        v.second.nVal = v.first.nKey;
+                        v.second.strVal = std::to_string( v.first.nKey );
+                    } ));
+                    break;
+                case 3:
+                    EXPECT_TRUE( m.insert( i, val ));
+                    EXPECT_FALSE( m.insert( i, val ));
+                    break;
+                case 4:
+                    EXPECT_TRUE( m.insert( i.nKey, val.strVal ));
+                    EXPECT_FALSE( m.insert( i.nKey, val.strVal ));
+                    break;
+                case 5:
+                    EXPECT_TRUE( m.insert( val.strVal, i.nKey ));
+                    EXPECT_FALSE( m.insert( val.strVal, i.nKey ));
+                    break;
+                case 6:
+                    EXPECT_TRUE( m.insert_with( i, []( map_pair& v ) {
+                        v.second.nVal = v.first.nKey;
+                        v.second.strVal = std::to_string( v.first.nKey );
+                    } ));
+                    EXPECT_FALSE( m.insert_with( i, []( map_pair& v ) {
+                        EXPECT_TRUE( false );
+                    } ));
+                    break;
+                case 7:
+                    EXPECT_TRUE( m.insert_with( i.nKey, []( map_pair& v ) {
+                        v.second.nVal = v.first.nKey;
+                        v.second.strVal = std::to_string( v.first.nKey );
+                    } ));
+                    EXPECT_FALSE( m.insert_with( i.nKey, []( map_pair& v ) {
+                        EXPECT_TRUE( false );
+                    } ));
+                    break;
+                case 8:
+                    EXPECT_TRUE( m.insert_with( val.strVal, []( map_pair& v ) {
+                        v.second.nVal = v.first.nKey;
+                        v.second.strVal = std::to_string( v.first.nKey );
+                    } ));
+                    EXPECT_FALSE( m.insert_with( val.strVal, []( map_pair& v ) {
+                        EXPECT_TRUE( false );
+                    } ));
+                    break;
+                case 9:
+                    updResult = m.update( i.nKey, []( map_pair&, map_pair* ) {
+                        EXPECT_TRUE( false );
+                    }, false );
+                    EXPECT_FALSE( updResult.first );
+                    EXPECT_FALSE( updResult.second );
+
+                    updResult = m.update( i.nKey, []( map_pair& v, map_pair* old ) {
+                        EXPECT_TRUE( old == nullptr );
+                        v.second.nVal = v.first.nKey;
+                    });
+                    EXPECT_TRUE( updResult.first );
+                    EXPECT_TRUE( updResult.second );
+
+                    updResult = m.update( i.nKey, []( map_pair& v, map_pair* old ) {
+                        ASSERT_FALSE( old == nullptr );
+                        EXPECT_EQ( v.first.nKey, old->second.nVal );
+                        v.second.nVal = old->second.nVal;
+                        v.second.strVal = std::to_string( old->second.nVal );
+                    } );
+                    EXPECT_TRUE( updResult.first );
+                    EXPECT_FALSE( updResult.second );
+                    break;
+                case 10:
+                    updResult = m.update( i, []( map_pair&, map_pair* ) {
+                        EXPECT_TRUE( false );
+                    }, false );
+                    EXPECT_FALSE( updResult.first );
+                    EXPECT_FALSE( updResult.second );
+
+                    updResult = m.update( i, []( map_pair& v, map_pair* old ) {
+                        EXPECT_TRUE( old == nullptr );
+                        v.second.nVal = v.first.nKey;
+                    });
+                    EXPECT_TRUE( updResult.first );
+                    EXPECT_TRUE( updResult.second );
+
+                    updResult = m.update( i, []( map_pair& v, map_pair* old ) {
+                        ASSERT_FALSE( old == nullptr );
+                        EXPECT_EQ( v.first.nKey, old->second.nVal );
+                        v.second.nVal = old->second.nVal;
+                        v.second.strVal = std::to_string( v.second.nVal );
+                    } );
+                    EXPECT_TRUE( updResult.first );
+                    EXPECT_FALSE( updResult.second );
+                    break;
+                case 11:
+                    updResult = m.update( val.strVal, []( map_pair&, map_pair* ) {
+                        EXPECT_TRUE( false );
+                    }, false );
+                    EXPECT_FALSE( updResult.first );
+                    EXPECT_FALSE( updResult.second );
+
+                    updResult = m.update( val.strVal, []( map_pair& v, map_pair* old ) {
+                        EXPECT_TRUE( old == nullptr );
+                        v.second.nVal = v.first.nKey;
+                    });
+                    EXPECT_TRUE( updResult.first );
+                    EXPECT_TRUE( updResult.second );
+
+                    updResult = m.update( val.strVal, []( map_pair& v, map_pair* old ) {
+                        ASSERT_FALSE( old == nullptr );
+                        EXPECT_EQ( v.first.nKey, old->second.nVal );
+                        v.second.nVal = old->second.nVal;
+                        v.second.strVal = std::to_string( v.second.nVal );
+                    } );
+                    EXPECT_TRUE( updResult.first );
+                    EXPECT_FALSE( updResult.second );
+                    break;
+                case 12:
+                    EXPECT_TRUE( m.emplace( i.nKey ));
+                    EXPECT_FALSE( m.emplace( i.nKey ));
+                    EXPECT_TRUE( m.find( i.nKey, []( map_pair& v ) {
+                        v.second.nVal = v.first.nKey;
+                        v.second.strVal = std::to_string( v.first.nKey );
+                    } ));
+                    break;
+                case 13:
+                    EXPECT_TRUE( m.emplace( i, i.nKey ));
+                    EXPECT_FALSE( m.emplace( i, i.nKey ));
+                    break;
+                case 14:
+                    {
+                        std::string str = val.strVal;
+                        EXPECT_TRUE( m.emplace( i, std::move( str )));
+                        EXPECT_TRUE( str.empty());
+                        str = val.strVal;
+                        EXPECT_FALSE( m.emplace( i, std::move( str )));
+                        EXPECT_TRUE( str.empty());
+                    }
+                    break;
+                case 15:
+                    {
+                        std::string str = val.strVal;
+                        EXPECT_TRUE( m.emplace( i, i.nKey, std::move( str )));
+                        EXPECT_TRUE( str.empty());
+                        str = val.strVal;
+                        EXPECT_FALSE( m.emplace( i, i.nKey, std::move( str )));
+                        EXPECT_TRUE( str.empty());
+                    }
+                    break;
+                case 16:
+                    {
+                        auto res = m.upsert( i, i.nKey, false );
+                        EXPECT_FALSE( res.first );
+                        EXPECT_FALSE( res.second );
+
+                        res = m.upsert( i, i.nKey );
+                        EXPECT_TRUE( res.first );
+                        EXPECT_TRUE( res.second );
+
+                        std::string str = val.strVal;
+                        res = m.upsert( i, std::move( str ));
+                        EXPECT_TRUE( res.first );
+                        EXPECT_FALSE( res.second );
+                        EXPECT_TRUE( str.empty() );
+                    }
+                    break;
+                }
+
+                EXPECT_TRUE( m.contains( i.nKey ));
+                EXPECT_TRUE( m.contains( i ));
+                EXPECT_TRUE( m.contains( other_item( i.nKey ), other_less()));
+                EXPECT_TRUE( m.find( i, []( map_pair const& v ) {
+                    EXPECT_EQ( v.first.nKey, v.second.nVal );
+                    EXPECT_EQ( std::to_string( v.first.nKey ), v.second.strVal );
+                } ));
+                EXPECT_TRUE( m.find( i.nKey, []( map_pair const& v ) {
+                    EXPECT_EQ( v.first.nKey, v.second.nVal );
+                    EXPECT_EQ( std::to_string( v.first.nKey ), v.second.strVal );
+                } ));
+                EXPECT_TRUE( m.find_with( other_item( i.nKey ), other_less(), []( map_pair const& v ) {
+                    EXPECT_EQ( v.first.nKey, v.second.nVal );
+                    EXPECT_EQ( std::to_string( v.first.nKey ), v.second.strVal );
+                } ));
+            }
+            EXPECT_FALSE( m.empty() );
+            EXPECT_CONTAINER_SIZE( m, kkSize );
+            EXPECT_FALSE( m.begin() == m.end() );
+            EXPECT_FALSE( m.cbegin() == m.cend() );
+
+            shuffle( arrKeys.begin(), arrKeys.end() );
+
+            // erase/find
+            for ( auto const& i : arrKeys ) {
+                value_type const& val( arrVals.at( i.nKey ) );
+
+                EXPECT_TRUE( m.contains( i.nKey ));
+                EXPECT_TRUE( m.contains( val.strVal ) );
+                EXPECT_TRUE( m.contains( i ));
+                EXPECT_TRUE( m.contains( other_item( i.nKey ), other_less()));
+                EXPECT_TRUE( m.find( i, []( map_pair const& v ) {
+                    EXPECT_EQ( v.first.nKey, v.second.nVal );
+                    EXPECT_EQ( std::to_string( v.first.nKey ), v.second.strVal );
+                } ));
+                EXPECT_TRUE( m.find( i.nKey, []( map_pair const& v ) {
+                    EXPECT_EQ( v.first.nKey, v.second.nVal );
+                    EXPECT_EQ( std::to_string( v.first.nKey ), v.second.strVal );
+                } ));
+                EXPECT_TRUE( m.find_with( other_item( i.nKey ), other_less(), []( map_pair const& v ) {
+                    EXPECT_EQ( v.first.nKey, v.second.nVal );
+                    EXPECT_EQ( std::to_string( v.first.nKey ), v.second.strVal );
+                } ));
+
+
+                switch ( i.nKey % 8 ) {
+                case 0:
+                    EXPECT_TRUE( m.erase( i ));
+                    EXPECT_FALSE( m.erase( i ));
+                    break;
+                case 1:
+                    EXPECT_TRUE( m.erase( i.nKey ));
+                    EXPECT_FALSE( m.erase( i.nKey ));
+                    break;
+                case 2:
+                    EXPECT_TRUE( m.erase( val.strVal ));
+                    EXPECT_FALSE( m.erase( val.strVal ));
+                    break;
+                case 3:
+                    EXPECT_TRUE( m.erase_with( other_item( i.nKey ), other_less()));
+                    EXPECT_FALSE( m.erase_with( other_item( i.nKey ), other_less()));
+                    break;
+                case 4:
+                    EXPECT_TRUE( m.erase( i, []( map_pair& v ) {
+                        EXPECT_EQ( v.first.nKey, v.second.nVal );
+                        EXPECT_EQ( std::to_string( v.first.nKey ), v.second.strVal );
+                    }));
+                    EXPECT_FALSE( m.erase( i, []( map_pair& ) {
+                        EXPECT_TRUE( false );
+                    }));
+                    break;
+                case 5:
+                    EXPECT_TRUE( m.erase( i.nKey, []( map_pair& v ) {
+                        EXPECT_EQ( v.first.nKey, v.second.nVal );
+                        EXPECT_EQ( std::to_string( v.first.nKey ), v.second.strVal );
+                    }));
+                    EXPECT_FALSE( m.erase( i.nKey, []( map_pair& ) {
+                        EXPECT_TRUE( false );
+                    }));
+                    break;
+                case 6:
+                    EXPECT_TRUE( m.erase( val.strVal, []( map_pair& v ) {
+                        EXPECT_EQ( v.first.nKey, v.second.nVal );
+                        EXPECT_EQ( std::to_string( v.first.nKey ), v.second.strVal );
+                    }));
+                    EXPECT_FALSE( m.erase( val.strVal, []( map_pair& ) {
+                        EXPECT_TRUE( false );
+                    }));
+                    break;
+                case 7:
+                    EXPECT_TRUE( m.erase_with( other_item( i.nKey ), other_less(), []( map_pair& v ) {
+                        EXPECT_EQ( v.first.nKey, v.second.nVal );
+                        EXPECT_EQ( std::to_string( v.first.nKey ), v.second.strVal );
+                    }));
+                    EXPECT_FALSE( m.erase_with( other_item( i.nKey ), other_less(), []( map_pair& ) {
+                        EXPECT_TRUE( false );
+                    }));
+                    break;
+                }
+
+                EXPECT_FALSE( m.contains( i.nKey ));
+                EXPECT_FALSE( m.contains( i ));
+                EXPECT_FALSE( m.contains( val.strVal ));
+                EXPECT_FALSE( m.contains( other_item( i.nKey ), other_less()));
+                EXPECT_FALSE( m.find( i, []( map_pair const& ) {
+                    EXPECT_TRUE( false );
+                } ));
+                EXPECT_FALSE( m.find( i.nKey, []( map_pair const& ) {
+                    EXPECT_TRUE( false );
+                } ));
+                EXPECT_FALSE( m.find_with( other_item( i.nKey ), other_less(), []( map_pair const& ) {
+                    EXPECT_TRUE( false );
+                } ));
+            }
+            EXPECT_TRUE( m.empty() );
+            EXPECT_CONTAINER_SIZE( m, 0 );
+
+            EXPECT_TRUE( m.begin() == m.end());
+            EXPECT_TRUE( m.cbegin() == m.cend());
+
+            // clear
+            for ( auto const& i : arrKeys )
+                EXPECT_TRUE( m.insert( i ));
+
+            EXPECT_FALSE( m.empty() );
+            EXPECT_CONTAINER_SIZE( m, kkSize );
+
+            m.clear();
+
+            EXPECT_TRUE( m.empty() );
+            EXPECT_CONTAINER_SIZE( m, 0 );
+        }
+    };
+
+} // namespace cds_test
+
+#endif // #ifndef CDSUNIT_MAP_TEST_MICHAEL_ITERABLE_MAP_H
diff --git a/test/unit/map/test_michael_iterable_hp.h b/test/unit/map/test_michael_iterable_hp.h
new file mode 100644 (file)
index 0000000..19258b6
--- /dev/null
@@ -0,0 +1,142 @@
+/*
+    This file is a part of libcds - Concurrent Data Structures library
+
+    (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016
+
+    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:
+
+    * Redistributions of source code must retain the above copyright notice, this
+      list of conditions and the following disclaimer.
+
+    * Redistributions in binary form must reproduce the above copyright notice,
+      this list of conditions and the following disclaimer in the documentation
+      and/or other materials provided with the distribution.
+
+    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+    AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+    IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+    DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+    FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+    DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+    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.
+*/
+
+#ifndef CDSUNIT_MAP_TEST_MICHAEL_ITERABLE_MAP_HP_H
+#define CDSUNIT_MAP_TEST_MICHAEL_ITERABLE_MAP_HP_H
+
+#include "test_michael_iterable.h"
+
+namespace cds_test {
+
+    class michael_iterable_hp: public michael_iterable_map
+    {
+        typedef michael_iterable_map base_class;
+
+    protected:
+        template <class Map>
+        void test( Map& m )
+        {
+            // Precondition: map is empty
+            // Postcondition: map is empty
+
+            base_class::test( m );
+
+            EXPECT_TRUE( m.empty());
+            EXPECT_CONTAINER_SIZE( m, 0 );
+
+            typedef typename Map::value_type map_pair;
+            size_t const kkSize = base_class::kSize;
+
+            std::vector<key_type> arrKeys;
+            for ( int i = 0; i < static_cast<int>(kkSize); ++i )
+                arrKeys.push_back( key_type( i ));
+            shuffle( arrKeys.begin(), arrKeys.end());
+
+            std::vector< value_type > arrVals;
+            for ( size_t i = 0; i < kkSize; ++i ) {
+                value_type val;
+                val.nVal = static_cast<int>( i );
+                val.strVal = std::to_string( i );
+                arrVals.push_back( val );
+            }
+
+            for ( auto const& i : arrKeys )
+                EXPECT_TRUE( m.insert( i ) );
+            EXPECT_FALSE( m.empty() );
+            EXPECT_CONTAINER_SIZE( m, kkSize );
+
+            // iterators
+            size_t nCount = 0;
+            for ( auto it = m.begin(); it != m.end(); ++it ) {
+                EXPECT_EQ( it->second.nVal, 0 );
+                it->second.nVal = it->first.nKey * 2;
+                ++nCount;
+            }
+            EXPECT_EQ( nCount, kkSize );
+
+            nCount = 0;
+            for ( auto it = m.cbegin(); it != m.cend(); ++it ) {
+                EXPECT_EQ( it->second.nVal, it->first.nKey * 2 );
+                ++nCount;
+            }
+            EXPECT_EQ( nCount, kkSize );
+
+            // get/extract
+            typedef typename Map::guarded_ptr guarded_ptr;
+            guarded_ptr gp;
+
+            for ( auto const& i : arrKeys ) {
+                value_type const& val = arrVals.at( i.nKey );
+
+                gp = m.get( i.nKey );
+                ASSERT_FALSE( !gp );
+                EXPECT_EQ( gp->first.nKey, i.nKey );
+                gp.release();
+                gp = m.get( i );
+                ASSERT_FALSE( !gp );
+                EXPECT_EQ( gp->first.nKey, i.nKey );
+                gp.release();
+                gp = m.get_with( other_item( i.nKey ), other_less());
+                ASSERT_FALSE( !gp );
+                EXPECT_EQ( gp->first.nKey, i.nKey );
+
+                switch ( i.nKey % 4 ) {
+                case 0:
+                    gp = m.extract( i.nKey );
+                    break;
+                case 1:
+                    gp = m.extract( i );
+                    break;
+                case 2:
+                    gp = m.extract( val.strVal );
+                    break;
+                case 3:
+                    gp = m.extract_with( other_item( i.nKey ), other_less());
+                    break;
+                }
+                ASSERT_FALSE( !gp );
+                EXPECT_EQ( gp->first.nKey, i.nKey );
+                gp.release();
+
+                gp = m.get( i.nKey );
+                ASSERT_TRUE( !gp );
+                gp = m.get( i );
+                ASSERT_TRUE( !gp );
+                gp = m.get_with( other_item( i.nKey ), other_less() );
+                ASSERT_TRUE( !gp );
+            }
+            EXPECT_TRUE( m.empty() );
+            EXPECT_CONTAINER_SIZE( m, 0 );
+        }
+    };
+
+} // namespace cds_test
+
+#endif // #ifndef CDSUNIT_MAP_TEST_MICHAEL_ITERABLE_MAP_HP_H