CuckooMap, CuckooSet:
authorkhizmax <libcds.dev@gmail.com>
Tue, 1 Sep 2015 19:31:01 +0000 (22:31 +0300)
committerkhizmax <libcds.dev@gmail.com>
Tue, 1 Sep 2015 19:31:01 +0000 (22:31 +0300)
- replaced ensure() with update()
- replaced find( key ) with contains( key )

MapDelOdd MT-test was refactored for CuckooMap

19 files changed:
cds/container/cuckoo_map.h
cds/container/cuckoo_set.h
cds/container/details/cuckoo_base.h
cds/container/lazy_kvlist_rcu.h
cds/container/michael_list_rcu.h
cds/container/split_list_set_nogc.h
cds/intrusive/cuckoo_set.h
cds/intrusive/lazy_list_nogc.h
projects/Win/vc12/cds.sln
projects/Win/vc12/unit-map-delodd.vcxproj
tests/data/test-debug.conf
tests/data/test-express.conf
tests/data/test.conf
tests/unit/map2/map_defs.h
tests/unit/map2/map_delodd.cpp
tests/unit/map2/map_delodd.h
tests/unit/map2/map_delodd_cuckoo.cpp
tests/unit/map2/map_type_cuckoo.h
tests/unit/print_cuckoo_stat.h

index b5204ffdb6f9dc8652739f4e10b965ac2a55b561..efc841a81608d5c2063a8538e7177dcad7839c8d 100644 (file)
@@ -486,46 +486,47 @@ namespace cds { namespace container {
             return false;
         }
 
-        /// Ensures that the \p key exists in the map
+        /// Updates the node
         /**
             The operation performs inserting or changing data with lock-free manner.
 
-            If the \p key not found in the map, then the new item created from \p key
-            is inserted into the map (note that in this case the \ref key_type should be
-            constructible from type \p K).
+            If \p key is not found in the map, then \p key is inserted iff \p bAllowInsert is \p true.
             Otherwise, the functor \p func is called with item found.
-            The functor \p Func may be a function with signature:
-            \code
-                void func( bool bNew, value_type& item );
-            \endcode
-            or a functor:
+            The functor \p func signature is:
             \code
                 struct my_functor {
                     void operator()( bool bNew, value_type& item );
                 };
             \endcode
-
             with arguments:
             - \p bNew - \p true if the item has been inserted, \p false otherwise
-            - \p item - item of the list
-
-            The functor may change any fields of the \p item.second that is \ref value_type.
+            - \p item - an item of the map for \p key
 
-            Returns <tt> std::pair<bool, bool> </tt> where \p first is true if operation is successfull,
-            \p second is true if new item has been added or \p false if the item with \p key
-            already is in the list.
+            Returns std::pair<bool, bool> where \p first is \p true if operation is successfull,
+            i.e. the node has been inserted or updated,
+            \p second is \p true if new item has been added or \p false if the item with \p key
+            already exists.
         */
         template <typename K, typename Func>
-        std::pair<bool, bool> ensure( K const& key, Func func )
+        std::pair<bool, bool> update( K const& key, Func func, bool bAllowInsert = true )
         {
             scoped_node_ptr pNode( alloc_node( key ));
-            std::pair<bool, bool> res = base_class::ensure( *pNode,
-                [&func](bool bNew, node_type& item, node_type const& ){ func( bNew, item.m_val ); }
+            std::pair<bool, bool> res = base_class::update( *pNode,
+                [&func](bool bNew, node_type& item, node_type const& ){ func( bNew, item.m_val ); },
+                bAllowInsert
             );
             if ( res.first && res.second )
                 pNode.release();
             return res;
         }
+        //@cond
+        template <typename K, typename Func>
+        CDS_DEPRECATED("ensure() is deprecated, use update()")
+        std::pair<bool, bool> ensure( K const& key, Func func )
+        {
+            return update( key, func, true ;)
+        }
+        //@endcond
 
         /// Delete \p key from the map
         /** \anchor cds_nonintrusive_CuckooMap_erase_val
@@ -651,32 +652,45 @@ namespace cds { namespace container {
                 [&f](node_type& item, K const& ) { f( item.m_val );});
         }
 
-        /// Find the key \p key
-        /** \anchor cds_nonintrusive_CuckooMap_find_val
-
+        /// Checks whether the map contains \p key
+        /**
             The function searches the item with key equal to \p key
             and returns \p true if it is found, and \p false otherwise.
         */
         template <typename K>
+        bool contains( K const& key )
+        {
+            return base_class::contains( key );
+        }
+        //@cond
+        template <typename K>
+        CDS_DEPRECATED("the function is deprecated, use contains()")
         bool find( K const& key )
         {
-            return base_class::find( key );
+            return contains( key );
         }
+        //@endcond
 
-        /// Find the key \p val using \p pred predicate for comparing
+        /// Checks whether the map contains \p key using \p pred predicate for searching
         /**
-            The function is an analog of \ref cds_nonintrusive_CuckooMap_find_val "find(K const&)"
-            but \p pred is used for key comparison.
-            If you use ordered cuckoo map, then \p Predicate should have the interface and semantics like \p std::less.
-            If you use unordered cuckoo map, then \p Predicate should have the interface and semantics like \p std::equal_to.
-            \p pred must imply the same element order as the comparator used for building the map.
+            The function is similar to <tt>contains( key )</tt> but \p pred is used for key comparing.
+            \p Less functor has the interface like \p std::less.
+            \p Less must imply the same element order as the comparator used for building the map.
         */
         template <typename K, typename Predicate>
-        bool find_with( K const& key, Predicate pred )
+        bool contains( K const& key, Predicate pred )
         {
             CDS_UNUSED( pred );
-            return base_class::find_with( key, cds::details::predicate_wrapper<node_type, Predicate, key_accessor>() );
+            return base_class::contains( key, cds::details::predicate_wrapper<node_type, Predicate, key_accessor>() );
         }
+        //@cond
+        template <typename K, typename Predicate>
+        CDS_DEPRECATED("the function is deprecated, use contains()")
+        bool find_with( K const& key, Predicate pred )
+        {
+            return contains( key, pred );
+        }
+        //@endcond
 
         /// Clears the map
         void clear()
index 1142cce7dc9bba7283ddca5fc742309121b36af7..741330144c164fb5c5dd1fc7232df64a82671109 100644 (file)
@@ -535,45 +535,51 @@ namespace cds { namespace container {
             return false;
         }
 
-        /// Ensures that the \p val exists in the set
+        /// Updates the node
         /**
-            The operation performs inserting or changing data.
+            The operation performs inserting or changing data with lock-free manner.
 
-            If the \p val key not found in the set, then the new item created from \p val
-            is inserted into the set. Otherwise, the functor \p func is called with the item found.
-            The functor \p Func should be a function with signature:
-            \code
-                void func( bool bNew, value_type& item, const Q& val );
-            \endcode
-            or a functor:
+            If the item \p val is not found in the set, then \p val is inserted into the set
+            iff \p bAllowInsert is \p true.
+            Otherwise, the functor \p func is called with item found.
+            The functor \p func signature is:
             \code
                 struct my_functor {
                     void operator()( bool bNew, value_type& item, const Q& val );
                 };
             \endcode
-
             with arguments:
             - \p bNew - \p true if the item has been inserted, \p false otherwise
             - \p item - item of the set
-            - \p val - argument \p val passed into the \p ensure function
+            - \p val - argument \p val passed into the \p %update() function
+            If new item has been inserted (i.e. \p bNew is \p true) then \p item and \p val arguments
+            refer to the same thing.
 
-            The functor can change non-key fields of the \p item.
-
-            Returns <tt> std::pair<bool, bool> </tt> where \p first is true if operation is successfull,
-            \p second is true if new item has been added or \p false if the item with \p val key
+            Returns std::pair<bool, bool> where \p first is \p true if operation is successfull,
+            i.e. the node has been inserted or updated,
+            \p second is \p true if new item has been added or \p false if the item with \p key
             already exists.
         */
         template <typename Q, typename Func>
-        std::pair<bool, bool> ensure( Q const& val, Func func )
+        std::pair<bool, bool> update( Q const& val, Func func, bool bAllowInsert = true )
         {
             scoped_node_ptr pNode( alloc_node( val ));
-            std::pair<bool, bool> res = base_class::ensure( *pNode,
-                [&val,&func](bool bNew, node_type& item, node_type const& ){ func( bNew, item.m_val, val ); }
+            std::pair<bool, bool> res = base_class::update( *pNode,
+                [&val,&func](bool bNew, node_type& item, node_type const& ){ func( bNew, item.m_val, val ); },
+                bAllowInsert
             );
             if ( res.first && res.second )
                 pNode.release();
             return res;
         }
+        //@cond
+        template <typename Q, typename Func>
+        CDS_DEPRECATED("ensure() is deprecated, use update()")
+        std::pair<bool, bool> ensure( Q const& val, Func func )
+        {
+            return update( val, func, true );
+        }
+        //@endcond
 
         /// Delete \p key from the set
         /** \anchor cds_nonintrusive_CuckooSet_erase
@@ -690,6 +696,13 @@ namespace cds { namespace container {
         {
             return base_class::find( val, [&f](node_type& item, Q& v) { f( item.m_val, v );});
         }
+        //@cond
+        template <typename Q, typename Func>
+        bool find( Q const& val, Func f )
+        {
+            return base_class::find( val, [&f](node_type& item, Q const& v) { f( item.m_val, v );});
+        }
+        //@endcond
 
         /// Find the key \p val using \p pred predicate for comparing
         /**
@@ -706,40 +719,7 @@ namespace cds { namespace container {
             return base_class::find_with( val, typename maker::template predicate_wrapper<Predicate, bool>(),
                 [&f](node_type& item, Q& v) { f( item.m_val, v );});
         }
-
-        /// Find the key \p val
-        /** \anchor cds_nonintrusive_CuckooSet_find_cfunc
-
-            The function searches the item with key equal to \p val and calls the functor \p f for item found.
-            The interface of \p Func functor is:
-            \code
-            struct functor {
-                void operator()( value_type& item, Q const& val );
-            };
-            \endcode
-            where \p item is the item found, \p val is the <tt>find</tt> function argument.
-
-            The functor can change non-key fields of \p item.
-
-            The type \p Q can differ from \ref value_type of items storing in the container.
-            Therefore, the \p value_type should be comparable with type \p Q.
-
-            The function returns \p true if \p val is found, \p false otherwise.
-        */
-        template <typename Q, typename Func>
-        bool find( Q const& val, Func f )
-        {
-            return base_class::find( val, [&f](node_type& item, Q const& v) { f( item.m_val, v );});
-        }
-
-        /// Find the key \p val using \p pred predicate for comparing
-        /**
-            The function is an analog of \ref cds_nonintrusive_CuckooSet_find_cfunc "find(Q const&, Func)"
-            but \p pred is used for key comparison.
-            If you use ordered cuckoo set, then \p Predicate should have the interface and semantics like \p std::less.
-            If you use unordered cuckoo set, then \p Predicate should have the interface and semantics like \p std::equal_to.
-            \p pred must imply the same element order as the comparator used for building the set.
-        */
+        //@cond
         template <typename Q, typename Predicate, typename Func>
         bool find_with( Q const& val, Predicate pred, Func f )
         {
@@ -747,36 +727,47 @@ namespace cds { namespace container {
             return base_class::find_with( val, typename maker::template predicate_wrapper<Predicate, bool>(),
                 [&f](node_type& item, Q const& v) { f( item.m_val, v );});
         }
+        //@endcond
 
-        /// Find the key \p val
-        /** \anchor cds_nonintrusive_CuckooSet_find_val
-
-            The function searches the item with key equal to \p val
+        /// Checks whether the set contains \p key
+        /**
+            The function searches the item with key equal to \p key
             and returns \p true if it is found, and \p false otherwise.
-
-            Note the hash functor specified for class \p Traits template parameter
-            should accept a parameter of type \p Q that can be not the same as \ref value_type.
         */
         template <typename Q>
-        bool find( Q const& val )
+        bool contains( Q const& key )
         {
-            return base_class::find( val, [](node_type&, Q const&) {});
+            return base_class::find( key, [](node_type&, Q const&) {});
         }
+        //@cond
+        template <typename Q>
+        CDS_DEPRECATED("the function is deprecated, use contains()")
+        bool find( Q const& key )
+        {
+            return contains( key );
+        }
+        //@endcond
 
-        /// Find the key \p val using \p pred predicate for comparing
+        /// Checks whether the set contains \p key using \p pred predicate for searching
         /**
-            The function is an analog of \ref cds_nonintrusive_CuckooSet_find_val "find(Q const&)"
-            but \p pred is used for key comparison.
-            If you use ordered cuckoo set, then \p Predicate should have the interface and semantics like \p std::less.
-            If you use unordered cuckoo set, then \p Predicate should have the interface and semantics like \p std::equal_to.
-            \p pred must imply the same element order as the comparator used for building the set.
+            The function is similar to <tt>contains( key )</tt> but \p pred is used for key comparing.
+            \p Less functor has the interface like \p std::less.
+            \p Less must imply the same element order as the comparator used for building the set.
         */
         template <typename Q, typename Predicate>
-        bool find_with( Q const& val, Predicate pred )
+        bool contains( Q const& key, Predicate pred )
         {
             CDS_UNUSED( pred );
-            return base_class::find_with( val, typename maker::template predicate_wrapper<Predicate, bool>(), [](node_type&, Q const&) {});
+            return base_class::find_with( key, typename maker::template predicate_wrapper<Predicate, bool>(), [](node_type&, Q const&) {});
+        }
+        //@cond
+        template <typename Q, typename Predicate>
+        CDS_DEPRECATED("the function is deprecated, use contains()")
+        bool find_with( Q const& key, Predicate pred )
+        {
+            return contains( key, pred );
         }
+        //@endcond
 
         /// Clears the set
         /**
index 34f07a2e7a570ad2963f9214e3e8f05b47dc09c5..d30c0621f1d0a86bc2455366a1dedd611d29ead0 100644 (file)
@@ -102,11 +102,7 @@ namespace cds { namespace container {
 #ifdef CDS_DOXYGEN_INVOKED
         /// Probe set type option
         /**
-            The option specifies probe set type for the CuckooSet and CuckooMap.
-            Available \p Type:
-            - \p cuckoo::list - the probe-set is a single-linked list.
-            - \p cuckoo::vector<Capacity> - the probe-set is a vector
-                with constant-size \p Capacity where \p Capacity is an <tt>unsigned int</tt> constant.
+            @copydetails cds::intrusive::cuckoo::probeset_type
         */
         template <typename Type>
         struct probeset_type
index 2bb6eaca5dfb5715ec92c1e83e19194fb93d5bba..6eb128508b2e911fea6db3aea6d23b9fe7e24f92 100644 (file)
@@ -450,7 +450,7 @@ namespace cds { namespace container {
         template <typename K, typename Func>
         std::pair<bool, bool> ensure( const K& key, Func f )
         {
-            return update( head(), key, f, true );
+            return update( key, f, true );
         }
         //@endcond
 
index 9cfaa1b794169f4b615d2c0508b8dac0f6614390..5377e1959c52ad36b58f2d69e9f530a3ef63636f 100644 (file)
@@ -428,7 +428,7 @@ namespace cds { namespace container {
         // Deprecated, use update()
         template <typename Q, typename Func>
         std::pair<bool, bool> ensure( Q const& key, Func f )
-        {1
+        {
             return update( key, f, true );
         }
         //@endcond
index f7ffd2592a6cb054af0ec31e315557686194d4b7..ad031f49e9f48eb7534979e22bc2191b0d6cab04 100644 (file)
@@ -306,7 +306,7 @@ namespace cds { namespace container {
 
             std::pair<typename base_class::iterator, bool> ret = base_class::update_( *pNode, 
                 [](bool /*bNew*/, node_type& /*item*/, node_type& /*val*/){},
-                bAllowInser );
+                bAllowInsert );
             if ( ret.first != base_class::end() && ret.second ) {
                 pNode.release();
                 return std::make_pair( iterator(ret.first), ret.second );
index be873686ec86b19a869ee448468b006370c282af..031aa2b2250eb28f221820687c41fcc2fff4ae16 100644 (file)
@@ -79,14 +79,17 @@ namespace cds { namespace intrusive {
         //@endcond
 
         //@cond
-        // Probeset type declarations.
+        /// List probeset type
         struct list;
+        //@endcond
+
+        /// Vector probeset type
         template <unsigned int Capacity>
         struct vector
         {
+            /// Vector capacity
             static unsigned int const c_nCapacity = Capacity;
         };
-        //@endcond
 
         /// CuckooSet node
         /**
@@ -172,7 +175,6 @@ namespace cds { namespace intrusive {
             {
                 m_pNext = nullptr;
             }
-
         };
 
         template <unsigned int VectorSize, typename Tag>
@@ -986,11 +988,11 @@ namespace cds { namespace intrusive {
             counter_type    m_nInsertRelocateCount  ;   ///< Count of \p relocate function call from \p insert
             counter_type    m_nInsertRelocateFault  ;   ///< Count of failed \p relocate function call from \p insert
 
-            counter_type    m_nEnsureExistCount     ;   ///< Count of call \p ensure function for existing node
-            counter_type    m_nEnsureSuccessCount   ;   ///< Count of successfull \p insert function call for new node
-            counter_type    m_nEnsureResizeCount    ;   ///< Count of \p resize function call from \p ensure
-            counter_type    m_nEnsureRelocateCount  ;   ///< Count of \p relocate function call from \p ensure
-            counter_type    m_nEnsureRelocateFault  ;   ///< Count of failed \p relocate function call from \p ensure
+            counter_type    m_nUpdateExistCount     ;   ///< Count of call \p update() function for existing node
+            counter_type    m_nUpdateSuccessCount   ;   ///< Count of successfull \p insert function call for new node
+            counter_type    m_nUpdateResizeCount    ;   ///< Count of \p resize function call from \p update()
+            counter_type    m_nUpdateRelocateCount  ;   ///< Count of \p relocate function call from \p update()
+            counter_type    m_nUpdateRelocateFault  ;   ///< Count of failed \p relocate function call from \p update()
 
             counter_type    m_nUnlinkSuccess        ;   ///< Count of success \p unlink function call
             counter_type    m_nUnlinkFailed         ;   ///< Count of failed \p unlink function call
@@ -1026,11 +1028,11 @@ namespace cds { namespace intrusive {
             void    onInsertRelocate()      { ++m_nInsertRelocateCount; }
             void    onInsertRelocateFault() { ++m_nInsertRelocateFault; }
 
-            void    onEnsureExist()         { ++m_nEnsureExistCount; }
-            void    onEnsureSuccess()       { ++m_nEnsureSuccessCount; }
-            void    onEnsureResize()        { ++m_nEnsureResizeCount; }
-            void    onEnsureRelocate()      { ++m_nEnsureRelocateCount; }
-            void    onEnsureRelocateFault() { ++m_nEnsureRelocateFault; }
+            void    onUpdateExist()         { ++m_nUpdateExistCount; }
+            void    onUpdateSuccess()       { ++m_nUpdateSuccessCount; }
+            void    onUpdateResize()        { ++m_nUpdateResizeCount; }
+            void    onUpdateRelocate()      { ++m_nUpdateRelocateCount; }
+            void    onUpdateRelocateFault() { ++m_nUpdateRelocateFault; }
 
             void    onUnlinkSuccess()       { ++m_nUnlinkSuccess; }
             void    onUnlinkFailed()        { ++m_nUnlinkFailed; }
@@ -1067,11 +1069,11 @@ namespace cds { namespace intrusive {
             void    onInsertRelocate()      const {}
             void    onInsertRelocateFault() const {}
 
-            void    onEnsureExist()         const {}
-            void    onEnsureSuccess()       const {}
-            void    onEnsureResize()        const {}
-            void    onEnsureRelocate()      const {}
-            void    onEnsureRelocateFault() const {}
+            void    onUpdateExist()         const {}
+            void    onUpdateSuccess()       const {}
+            void    onUpdateResize()        const {}
+            void    onUpdateRelocate()      const {}
+            void    onUpdateRelocateFault() const {}
 
             void    onUnlinkSuccess()       const {}
             void    onUnlinkFailed()        const {}
@@ -1984,7 +1986,6 @@ namespace cds { namespace intrusive {
         static void store_hash( node_type * pNode, size_t * pHashes )
         {
             cuckoo::details::hash_ops< node_type, c_nNodeHashArraySize >::store( pNode, pHashes );
-            //memcpy( pNode->m_arrHash, pHashes, sizeof(size_t) * c_nArity );
         }
 
         static bool equal_hash( node_type& node, unsigned int nTable, size_t nHash )
@@ -2015,7 +2016,7 @@ namespace cds { namespace intrusive {
             free_bucket_tables( m_BucketTable, m_nBucketMask + 1 );
         }
 
-        static unsigned int const c_nUndefTable = (unsigned int) -1;
+        static CDS_CONSTEXPR unsigned int const c_nUndefTable = (unsigned int) -1;
         template <typename Q, typename Predicate >
         unsigned int contains( position * arrPos, size_t * arrHash, Q const& val, Predicate pred )
         {
@@ -2436,31 +2437,33 @@ namespace cds { namespace intrusive {
             return true;
         }
 
-        /// Ensures that the \p val exists in the set
+        /// Updates the node
         /**
             The operation performs inserting or changing data with lock-free manner.
 
-            If the item \p val not found in the set, then \p val is inserted into the set.
+            If the item \p val is not found in the set, then \p val is inserted into the set
+            iff \p bAllowInsert is \p true.
             Otherwise, the functor \p func is called with item found.
-            The functor signature is:
+            The functor \p func signature is:
             \code
                 void func( bool bNew, value_type& item, value_type& val );
             \endcode
             with arguments:
             - \p bNew - \p true if the item has been inserted, \p false otherwise
             - \p item - item of the set
-            - \p val - argument \p val passed into the \p ensure function
+            - \p val - argument \p val passed into the \p %update() function
             If new item has been inserted (i.e. \p bNew is \p true) then \p item and \p val arguments
-            refers to the same thing.
+            refer to the same thing.
 
             The functor may change non-key fields of the \p item.
 
-            Returns <tt> std::pair<bool, bool> </tt> where \p first is \p true if operation is successful,
+            Returns std::pair<bool, bool> where \p first is \p true if operation is successfull,
+            i.e. the node has been inserted or updated,
             \p second is \p true if new item has been added or \p false if the item with \p key
-            already is in the set.
+            already exists.
         */
         template <typename Func>
-        std::pair<bool, bool> ensure( value_type& val, Func func )
+        std::pair<bool, bool> update( value_type& val, Func func, bool bAllowInsert = true )
         {
             hash_array arrHash;
             position arrPos[ c_nArity ];
@@ -2477,12 +2480,15 @@ namespace cds { namespace intrusive {
                     unsigned int nTable = contains( arrPos, arrHash, val, key_predicate() );
                     if ( nTable != c_nUndefTable ) {
                         func( false, *node_traits::to_value_ptr( *arrPos[nTable].itFound ), val );
-                        m_Stat.onEnsureExist();
+                        m_Stat.onUpdateExist();
                         return std::make_pair( true, false );
                     }
 
-                    node_type * pNode = node_traits::to_node_ptr( val );
-                    store_hash( pNode, arrHash );
+                    if ( !bAllowInsert )
+                        return std::make_pair( false, false );
+
+                    //node_type * pNode = node_traits::to_node_ptr( val );
+                    //store_hash( pNode, arrHash );
 
                     for ( unsigned int i = 0; i < c_nArity; ++i ) {
                         bucket_entry& refBucket = bucket( i, arrHash[i] );
@@ -2490,7 +2496,7 @@ namespace cds { namespace intrusive {
                             refBucket.insert_after( arrPos[i].itPrev, pNode );
                             func( true, val, val );
                             ++m_ItemCounter;
-                            m_Stat.onEnsureSuccess();
+                            m_Stat.onUpdateSuccess();
                             return std::make_pair( true, true );
                         }
                     }
@@ -2509,21 +2515,29 @@ namespace cds { namespace intrusive {
                     }
                 }
 
-                m_Stat.onEnsureResize();
+                m_Stat.onUpdateResize();
                 resize();
             }
 
         do_relocate:
-            m_Stat.onEnsureRelocate();
+            m_Stat.onUpdateRelocate();
             if ( !relocate( nGoalTable, arrHash )) {
-                m_Stat.onEnsureRelocateFault();
-                m_Stat.onEnsureResize();
+                m_Stat.onUpdateRelocateFault();
+                m_Stat.onUpdateResize();
                 resize();
             }
 
-            m_Stat.onEnsureSuccess();
+            m_Stat.onUpdateSuccess();
             return std::make_pair( true, true );
         }
+        //@cond
+        // Deprecated, use update()
+        template <typename Func>
+        std::pair<bool, bool> ensure( value_type& val, Func func )
+        {
+            return update( val, func, true );
+        }
+        //@endcond
 
         /// Unlink the item \p val from the set
         /**
@@ -2649,6 +2663,13 @@ namespace cds { namespace intrusive {
         {
             return find_( val, key_predicate(), f );
         }
+        //@cond
+        template <typename Q, typename Func>
+        bool find( Q const& val, Func f )
+        {
+            return find_( val, key_predicate(), f );
+        }
+        //@endcond
 
         /// Find the key \p val using \p pred predicate for comparing
         /**
@@ -2664,74 +2685,54 @@ namespace cds { namespace intrusive {
             CDS_UNUSED( pred );
             return find_( val, typename predicate_wrapper<Predicate>::type(), f );
         }
-
-        /// Find the key \p val
-        /** \anchor cds_intrusive_CuckooSet_find_cfunc
-            The function searches the item with key equal to \p val and calls the functor \p f for item found.
-            The interface of \p Func functor is:
-            \code
-            struct functor {
-                void operator()( value_type& item, Q const& val );
-            };
-            \endcode
-            where \p item is the item found, \p val is the <tt>find</tt> function argument.
-
-            The functor may change non-key fields of \p item.
-
-            The \p val argument is non-const since it can be used as \p f functor destination i.e., the functor
-            may modify both arguments.
-
-            The function returns \p true if \p val is found, \p false otherwise.
-        */
-        template <typename Q, typename Func>
-        bool find( Q const& val, Func f )
-        {
-            return find_( val, key_predicate(), f );
-        }
-
-        /// Find the key \p val using \p pred predicate for comparing
-        /**
-            The function is an analog of \ref cds_intrusive_CuckooSet_find_cfunc "find(Q const&, Func)"
-            but \p pred is used for key comparison.
-            If you use ordered cuckoo set, then \p Predicate should have the interface and semantics like \p std::less.
-            If you use unordered cuckoo set, then \p Predicate should have the interface and semantics like \p std::equal_to.
-            \p pred must imply the same element order as the comparator used for building the set.
-        */
+        //@cond
         template <typename Q, typename Predicate, typename Func>
         bool find_with( Q const& val, Predicate pred, Func f )
         {
             CDS_UNUSED( pred );
             return find_( val, typename predicate_wrapper<Predicate>::type(), f );
         }
+        //@endcond
 
-        /// Find the key \p val
-        /** \anchor cds_intrusive_CuckooSet_find_val
-            The function searches the item with key equal to \p val
+        /// Checks whether the set contains \p key
+        /**
+            The function searches the item with key equal to \p key
             and returns \p true if it is found, and \p false otherwise.
-
-            Note the hash functor specified for class \p Traits template parameter
-            should accept a parameter of type \p Q that can be not the same as \p value_type.
         */
         template <typename Q>
-        bool find( Q const& val )
+        bool contains( Q const& key )
         {
-            return find( val, [](value_type&, Q const& ) {} );
+            return find( key, [](value_type&, Q const& ) {} );
         }
+        //@cond
+        // Deprecated, use contains()
+        template <typename Q>
+        bool find( Q const& key )
+        {
+            return contains( key );
+        }
+        //@endcond
 
-        /// Find the key \p val using \p pred predicate for comparing
+        /// Checks whether the set contains \p key using \p pred predicate for searching
         /**
-            The function is an analog of \ref cds_intrusive_CuckooSet_find_val "find(Q const&)"
-            but \p pred is used for key comparison.
-            If you use ordered cuckoo set, then \p Predicate should have the interface and semantics like \p std::less.
-            If you use unordered cuckoo set, then \p Predicate should have the interface and semantics like \p std::equal_to.
-            \p pred must imply the same element order as the comparator used for building the set.
+            The function is similar to <tt>contains( key )</tt> but \p pred is used for key comparing.
+            \p Less functor has the interface like \p std::less.
+            \p Less must imply the same element order as the comparator used for building the set.
         */
         template <typename Q, typename Predicate>
-        bool find_with( Q const& val, Predicate pred )
+        bool contains( Q const& key, Predicate pred )
         {
             CDS_UNUSED( pred );
-            return find_with( val, typename predicate_wrapper<Predicate>::type(), [](value_type& , Q const& ) {} );
+            return find_with( key, typename predicate_wrapper<Predicate>::type(), [](value_type& , Q const& ) {} );
         }
+        //@cond
+        // Deprecated,use contains()
+        template <typename Q, typename Predicate>
+        bool find_with( Q const& key, Predicate pred )
+        {
+            return contains( key, pred );
+        }
+        //@endcond
 
         /// Clears the set
         /**
index 40595f182bc4034231df82c4d48cd4034b462bb4..6ecb29bfa190206d05c90f22f58d4c39538152d0 100644 (file)
@@ -380,7 +380,7 @@ namespace cds { namespace intrusive {
         template <typename Func>
         std::pair<bool, bool> ensure( value_type& val, Func func )
         {
-            return update( &m_Head, val, func, true );
+            return update( val, func, true );
         }
         //@endcond
 
index 8f96230c70faa398a639a19803e184ba3ccf17a2..a203d44cefdb1870072a502f4a0897893d73d714 100644 (file)
@@ -415,7 +415,6 @@ Global
                {BA2A9239-0299-4069-BB0E-16DACE87ADE0}.DebugVLD|Win32.ActiveCfg = DebugVLD|Win32\r
                {BA2A9239-0299-4069-BB0E-16DACE87ADE0}.DebugVLD|Win32.Build.0 = DebugVLD|Win32\r
                {BA2A9239-0299-4069-BB0E-16DACE87ADE0}.DebugVLD|x64.ActiveCfg = DebugVLD|x64\r
-               {BA2A9239-0299-4069-BB0E-16DACE87ADE0}.DebugVLD|x64.Build.0 = DebugVLD|x64\r
                {BA2A9239-0299-4069-BB0E-16DACE87ADE0}.ICL-Debug|Win32.ActiveCfg = ICL-Debug|Win32\r
                {BA2A9239-0299-4069-BB0E-16DACE87ADE0}.ICL-Debug|Win32.Build.0 = ICL-Debug|Win32\r
                {BA2A9239-0299-4069-BB0E-16DACE87ADE0}.ICL-Debug|x64.ActiveCfg = ICL-Debug|x64\r
@@ -435,7 +434,6 @@ Global
                {CA25BDBF-B354-4597-B6D2-220ABBB0D2F4}.DebugVLD|Win32.ActiveCfg = DebugVLD|Win32\r
                {CA25BDBF-B354-4597-B6D2-220ABBB0D2F4}.DebugVLD|Win32.Build.0 = DebugVLD|Win32\r
                {CA25BDBF-B354-4597-B6D2-220ABBB0D2F4}.DebugVLD|x64.ActiveCfg = DebugVLD|x64\r
-               {CA25BDBF-B354-4597-B6D2-220ABBB0D2F4}.DebugVLD|x64.Build.0 = DebugVLD|x64\r
                {CA25BDBF-B354-4597-B6D2-220ABBB0D2F4}.ICL-Debug|Win32.ActiveCfg = ICL-Debug|Win32\r
                {CA25BDBF-B354-4597-B6D2-220ABBB0D2F4}.ICL-Debug|Win32.Build.0 = ICL-Debug|Win32\r
                {CA25BDBF-B354-4597-B6D2-220ABBB0D2F4}.ICL-Debug|x64.ActiveCfg = ICL-Debug|x64\r
@@ -635,7 +633,6 @@ Global
                {7521DD92-56FF-4ECA-93E5-CCE50862354B}.DebugVLD|Win32.ActiveCfg = DebugVLD|Win32\r
                {7521DD92-56FF-4ECA-93E5-CCE50862354B}.DebugVLD|Win32.Build.0 = DebugVLD|Win32\r
                {7521DD92-56FF-4ECA-93E5-CCE50862354B}.DebugVLD|x64.ActiveCfg = DebugVLD|x64\r
-               {7521DD92-56FF-4ECA-93E5-CCE50862354B}.DebugVLD|x64.Build.0 = DebugVLD|x64\r
                {7521DD92-56FF-4ECA-93E5-CCE50862354B}.ICL-Debug|Win32.ActiveCfg = ICL-Debug|Win32\r
                {7521DD92-56FF-4ECA-93E5-CCE50862354B}.ICL-Debug|Win32.Build.0 = ICL-Debug|Win32\r
                {7521DD92-56FF-4ECA-93E5-CCE50862354B}.ICL-Debug|x64.ActiveCfg = ICL-Debug|x64\r
@@ -655,7 +652,6 @@ Global
                {CA6F0834-0628-4CD7-8800-AEABCD636360}.DebugVLD|Win32.ActiveCfg = DebugVLD|Win32\r
                {CA6F0834-0628-4CD7-8800-AEABCD636360}.DebugVLD|Win32.Build.0 = DebugVLD|Win32\r
                {CA6F0834-0628-4CD7-8800-AEABCD636360}.DebugVLD|x64.ActiveCfg = DebugVLD|x64\r
-               {CA6F0834-0628-4CD7-8800-AEABCD636360}.DebugVLD|x64.Build.0 = DebugVLD|x64\r
                {CA6F0834-0628-4CD7-8800-AEABCD636360}.ICL-Debug|Win32.ActiveCfg = ICL-Debug|Win32\r
                {CA6F0834-0628-4CD7-8800-AEABCD636360}.ICL-Debug|Win32.Build.0 = ICL-Debug|Win32\r
                {CA6F0834-0628-4CD7-8800-AEABCD636360}.ICL-Debug|x64.ActiveCfg = ICL-Debug|x64\r
index fae5da4bf1037df702554f5d952afd54c5275d12..4ceb02afce897ce749c487b8a6da9c149a8661d1 100644 (file)
@@ -48,7 +48,7 @@
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='DebugVLD|x64'">false</ExcludedFromBuild>\r
     </ClCompile>\r
     <ClCompile Include="..\..\..\tests\unit\map2\map_delodd_cuckoo.cpp">\r
-      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='DebugVLD|x64'">true</ExcludedFromBuild>\r
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='DebugVLD|x64'">false</ExcludedFromBuild>\r
     </ClCompile>\r
     <ClCompile Include="..\..\..\tests\unit\map2\map_delodd_ellentree.cpp">\r
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='DebugVLD|x64'">false</ExcludedFromBuild>\r
index c765db2b1824f358185e6cef7563b40c52efb974..df31370c9a8f6576ffde8eca282b4ee8c23a6d34 100644 (file)
@@ -193,4 +193,9 @@ InsThreadCount=2
 DelThreadCount=2\r
 ExtractThreadCount=2\r
 MaxLoadFactor=4\r
-PrintGCStateFlag=1
\ No newline at end of file
+PrintGCStateFlag=1\r
+#Cuckoo map properties\r
+CuckooInitialSize=256\r
+CuckooProbesetSize=8\r
+# 0 - use default\r
+CuckooProbesetThreshold=0 \r
index 8b285e8d0983905e1c71f19f8c9b2cdab9b86e72..04965af44d0f36ae675e06cce2d245a60eef5f4e 100644 (file)
@@ -191,4 +191,9 @@ InsThreadCount=4
 DelThreadCount=3\r
 ExtractThreadCount=3\r
 MaxLoadFactor=4\r
-PrintGCStateFlag=1
\ No newline at end of file
+PrintGCStateFlag=1\r
+#Cuckoo map properties\r
+CuckooInitialSize=1024\r
+CuckooProbesetSize=16\r
+# 0 - use default\r
+CuckooProbesetThreshold=0 \r
index a5468fca8094bf8978be9fd50149a090dd078c5e..62327b6a568f8c5f165734fe55a8ad27b52f146a 100644 (file)
@@ -187,3 +187,8 @@ DelThreadCount=3
 ExtractThreadCount=3\r
 MaxLoadFactor=4\r
 PrintGCStateFlag=1\r
+#Cuckoo map properties\r
+CuckooInitialSize=1024\r
+CuckooProbesetSize=16\r
+# 0 - use default\r
+CuckooProbesetThreshold=0 \r
index f8559b3096edf97d05266cb61fa693a2a380a7ab..96c9378771173b7e0590e73f3d795e28a9e93d83 100644 (file)
 // CuckooMap
 
 #define CDSUNIT_DECLARE_CuckooMap \
-    CDSUNIT_DECLARE_TEST(CuckooStripedMap_list_unord)\
-    CDSUNIT_DECLARE_TEST(CuckooStripedMap_list_ord)\
-    CDSUNIT_DECLARE_TEST(CuckooStripedMap_vector_unord)\
-    CDSUNIT_DECLARE_TEST(CuckooStripedMap_vector_ord)\
-    CDSUNIT_DECLARE_TEST(CuckooStripedMap_list_unord_stat)\
-    CDSUNIT_DECLARE_TEST(CuckooStripedMap_list_ord_stat)\
-    CDSUNIT_DECLARE_TEST(CuckooStripedMap_vector_unord_stat)\
-    CDSUNIT_DECLARE_TEST(CuckooStripedMap_vector_ord_stat)\
-    CDSUNIT_DECLARE_TEST(CuckooRefinableMap_list_unord)\
-    CDSUNIT_DECLARE_TEST(CuckooRefinableMap_list_ord)\
-    CDSUNIT_DECLARE_TEST(CuckooRefinableMap_vector_unord)\
-    CDSUNIT_DECLARE_TEST(CuckooRefinableMap_vector_ord) \
-    CDSUNIT_DECLARE_TEST(CuckooRefinableMap_list_unord_stat)\
-    CDSUNIT_DECLARE_TEST(CuckooRefinableMap_list_ord_stat)\
-    CDSUNIT_DECLARE_TEST(CuckooRefinableMap_vector_unord_stat)\
-    CDSUNIT_DECLARE_TEST(CuckooRefinableMap_vector_ord_stat) \
-    CDSUNIT_DECLARE_TEST(CuckooStripedMap_list_unord_storehash)\
-    CDSUNIT_DECLARE_TEST(CuckooStripedMap_list_ord_storehash)\
-    CDSUNIT_DECLARE_TEST(CuckooStripedMap_vector_unord_storehash)\
-    CDSUNIT_DECLARE_TEST(CuckooStripedMap_vector_ord_storehash)\
-    CDSUNIT_DECLARE_TEST(CuckooRefinableMap_list_unord_storehash)\
-    CDSUNIT_DECLARE_TEST(CuckooRefinableMap_list_ord_storehash)\
-    CDSUNIT_DECLARE_TEST(CuckooRefinableMap_vector_unord_storehash)\
-    CDSUNIT_DECLARE_TEST(CuckooRefinableMap_vector_ord_storehash)
-
-#define CDSUNIT_DEFINE_CuckooMap( IMPL, C ) \
-    TEST_MAP(IMPL, C, CuckooStripedMap_list_unord)\
-    TEST_MAP(IMPL, C, CuckooStripedMap_list_ord)\
-    TEST_MAP(IMPL, C, CuckooStripedMap_vector_unord)\
-    TEST_MAP(IMPL, C, CuckooStripedMap_vector_ord)\
-    TEST_MAP(IMPL, C, CuckooStripedMap_list_unord_stat)\
-    TEST_MAP(IMPL, C, CuckooStripedMap_list_ord_stat)\
-    TEST_MAP(IMPL, C, CuckooStripedMap_vector_unord_stat)\
-    TEST_MAP(IMPL, C, CuckooStripedMap_vector_ord_stat)\
-    TEST_MAP(IMPL, C, CuckooRefinableMap_list_unord)\
-    TEST_MAP(IMPL, C, CuckooRefinableMap_list_ord)\
-    TEST_MAP(IMPL, C, CuckooRefinableMap_vector_unord)\
-    TEST_MAP(IMPL, C, CuckooRefinableMap_vector_ord) \
-    TEST_MAP(IMPL, C, CuckooRefinableMap_list_unord_stat)\
-    TEST_MAP(IMPL, C, CuckooRefinableMap_list_ord_stat)\
-    TEST_MAP(IMPL, C, CuckooRefinableMap_vector_unord_stat)\
-    TEST_MAP(IMPL, C, CuckooRefinableMap_vector_ord_stat) \
-    TEST_MAP(IMPL, C, CuckooStripedMap_list_unord_storehash)\
-    TEST_MAP(IMPL, C, CuckooStripedMap_list_ord_storehash)\
-    TEST_MAP(IMPL, C, CuckooStripedMap_vector_unord_storehash)\
-    TEST_MAP(IMPL, C, CuckooStripedMap_vector_ord_storehash)\
-    TEST_MAP(IMPL, C, CuckooRefinableMap_list_unord_storehash)\
-    TEST_MAP(IMPL, C, CuckooRefinableMap_list_ord_storehash)\
-    TEST_MAP(IMPL, C, CuckooRefinableMap_vector_unord_storehash)\
-    TEST_MAP(IMPL, C, CuckooRefinableMap_vector_ord_storehash)
+    TEST_CASE(tag_CuckooMap, CuckooStripedMap_list_unord)\
+    TEST_CASE(tag_CuckooMap, CuckooStripedMap_list_ord)\
+    TEST_CASE(tag_CuckooMap, CuckooStripedMap_vector_unord)\
+    TEST_CASE(tag_CuckooMap, CuckooStripedMap_vector_ord)\
+    TEST_CASE(tag_CuckooMap, CuckooStripedMap_list_unord_stat)\
+    TEST_CASE(tag_CuckooMap, CuckooStripedMap_list_ord_stat)\
+    TEST_CASE(tag_CuckooMap, CuckooStripedMap_vector_unord_stat)\
+    TEST_CASE(tag_CuckooMap, CuckooStripedMap_vector_ord_stat)\
+    TEST_CASE(tag_CuckooMap, CuckooRefinableMap_list_unord)\
+    TEST_CASE(tag_CuckooMap, CuckooRefinableMap_list_ord)\
+    TEST_CASE(tag_CuckooMap, CuckooRefinableMap_vector_unord)\
+    TEST_CASE(tag_CuckooMap, CuckooRefinableMap_vector_ord) \
+    TEST_CASE(tag_CuckooMap, CuckooRefinableMap_list_unord_stat)\
+    TEST_CASE(tag_CuckooMap, CuckooRefinableMap_list_ord_stat)\
+    TEST_CASE(tag_CuckooMap, CuckooRefinableMap_vector_unord_stat)\
+    TEST_CASE(tag_CuckooMap, CuckooRefinableMap_vector_ord_stat) \
+    TEST_CASE(tag_CuckooMap, CuckooStripedMap_list_unord_storehash)\
+    TEST_CASE(tag_CuckooMap, CuckooStripedMap_list_ord_storehash)\
+    TEST_CASE(tag_CuckooMap, CuckooStripedMap_vector_unord_storehash)\
+    TEST_CASE(tag_CuckooMap, CuckooStripedMap_vector_ord_storehash)\
+    TEST_CASE(tag_CuckooMap, CuckooRefinableMap_list_unord_storehash)\
+    TEST_CASE(tag_CuckooMap, CuckooRefinableMap_list_ord_storehash)\
+    TEST_CASE(tag_CuckooMap, CuckooRefinableMap_vector_unord_storehash)\
+    TEST_CASE(tag_CuckooMap, CuckooRefinableMap_vector_ord_storehash)
 
 #define CDSUNIT_TEST_CuckooMap \
     CPPUNIT_TEST(CuckooStripedMap_list_unord)\
index 795d58d680496a2aeed908045c8597a56ac3a57d..2bee64ed9402c57c58915887650e268d2c79fc14 100644 (file)
@@ -12,8 +12,10 @@ namespace map2 {
         c_nExtractThreadCount = cfg.getULong("ExtractThreadCount", static_cast<unsigned long>(c_nExtractThreadCount) );
         c_nMaxLoadFactor = cfg.getULong("MaxLoadFactor", static_cast<unsigned long>(c_nMaxLoadFactor) );
         c_bPrintGCState = cfg.getBool("PrintGCStateFlag", true );
-        c_nMultiLevelMap_HeadBits = cfg.getULong("MultiLevelMap_HeadBits", static_cast<unsigned long>(c_nMultiLevelMap_HeadBits) );
-        c_nMultiLevelMap_ArrayBits = cfg.getULong("MultiLevelMap_ArrayBits", static_cast<unsigned long>(c_nMultiLevelMap_ArrayBits) );
+
+        c_nCuckooInitialSize = cfg.getULong("CuckooInitialSize", static_cast<unsigned long>(c_nCuckooInitialSize) );
+        c_nCuckooProbesetSize = cfg.getULong("CuckooProbesetSize", static_cast<unsigned long>(c_nCuckooProbesetSize) );
+        c_nCuckooProbesetThreshold = cfg.getULong("CuckooProbesetThreshold", static_cast<unsigned long>(c_nCuckooProbesetThreshold) );
 
 
         if ( c_nInsThreadCount == 0 )
index 57a6db6f8257fe2c364eb8ff7cf8cfc24b4bd5eb..61908482d66955b91ab3b482ba5574fc219f4336 100644 (file)
@@ -120,8 +120,9 @@ namespace map2 {
         size_t  c_nExtractThreadCount = 4;  // extract thread count
         size_t  c_nMapSize = 1000000;       // max map size
         size_t  c_nMaxLoadFactor = 8;       // maximum load factor
-        size_t  c_nMultiLevelMap_HeadBits = 10; // for MultiLevelHashMap - log2(size of head array)
-        size_t  c_nMultiLevelMap_ArrayBits = 8; // for MultiLevelHashMap - log2(size of array node)
+        size_t  c_nCuckooInitialSize = 1024;// initial size for CuckooMap
+        size_t  c_nCuckooProbesetSize = 16; // CuckooMap probeset size (only for list-based probeset)
+        size_t  c_nCuckooProbesetThreshold = 0; // CUckooMap probeset threshold (o - use default)
 
         bool    c_bPrintGCState = true;
 
@@ -651,39 +652,44 @@ namespace map2 {
         template <class Map>
         void run_test()
         {
-            if ( Map::c_bExtractSupported ) {
-                CPPUNIT_MSG( "Thread count: insert=" << c_nInsThreadCount
-                    << ", delete=" << c_nDelThreadCount
-                    << ", extract=" << c_nExtractThreadCount
-                    << "; set size=" << c_nMapSize
-                    );
-                if ( Map::c_bLoadFactorDepended ) {
-                    for ( c_nLoadFactor = 1; c_nLoadFactor <= c_nMaxLoadFactor; c_nLoadFactor *= 2 ) {
-                        CPPUNIT_MSG( "Load factor=" << c_nLoadFactor );
-                        do_test_extract<Map>();
-                        if ( c_bPrintGCState )
-                            print_gc_state();
-                    }
-                }
-                else
+            static_assert( Map::c_bExtractSupported, "Map class must support extract() method" );
+
+            CPPUNIT_MSG( "Thread count: insert=" << c_nInsThreadCount
+                << ", delete=" << c_nDelThreadCount
+                << ", extract=" << c_nExtractThreadCount
+                << "; set size=" << c_nMapSize
+                );
+            if ( Map::c_bLoadFactorDepended ) {
+                for ( c_nLoadFactor = 1; c_nLoadFactor <= c_nMaxLoadFactor; c_nLoadFactor *= 2 ) {
+                    CPPUNIT_MSG( "Load factor=" << c_nLoadFactor );
                     do_test_extract<Map>();
-            }
-            else {
-                CPPUNIT_MSG( "Insert thread count=" << c_nInsThreadCount
-                    << " delete thread count=" << c_nDelThreadCount
-                    << " set size=" << c_nMapSize
-                    );
-                if ( Map::c_bLoadFactorDepended ) {
-                    for ( c_nLoadFactor = 1; c_nLoadFactor <= c_nMaxLoadFactor; c_nLoadFactor *= 2 ) {
-                        CPPUNIT_MSG( "Load factor=" << c_nLoadFactor );
-                        do_test<Map>();
-                        if ( c_bPrintGCState )
-                            print_gc_state();
-                    }
+                    if ( c_bPrintGCState )
+                        print_gc_state();
                 }
-                else
+            }
+            else
+                do_test_extract<Map>();
+        }
+
+        template <class Map>
+        void run_test_no_extract()
+        {
+            static_assert( !Map::c_bExtractSupported, "Map class must not support extract() method" );
+
+            CPPUNIT_MSG( "Insert thread count=" << c_nInsThreadCount
+                << " delete thread count=" << c_nDelThreadCount
+                << " set size=" << c_nMapSize
+                );
+            if ( Map::c_bLoadFactorDepended ) {
+                for ( c_nLoadFactor = 1; c_nLoadFactor <= c_nMaxLoadFactor; c_nLoadFactor *= 2 ) {
+                    CPPUNIT_MSG( "Load factor=" << c_nLoadFactor );
                     do_test<Map>();
+                    if ( c_bPrintGCState )
+                        print_gc_state();
+                }
             }
+            else
+                do_test<Map>();
         }
 
         void setUpParams( const CppUnitMini::TestCfg& cfg );
@@ -694,6 +700,7 @@ namespace map2 {
         CDSUNIT_DECLARE_SkipListMap
         CDSUNIT_DECLARE_EllenBinTreeMap
         CDSUNIT_DECLARE_BronsonAVLTreeMap
+        CDSUNIT_DECLARE_CuckooMap
 
         // This test is not suitable for MultiLevelHashMap
         //CDSUNIT_DECLARE_MultiLevelHashMap
@@ -704,14 +711,13 @@ namespace map2 {
             CDSUNIT_TEST_SkipListMap
             CDSUNIT_TEST_EllenBinTreeMap
             CDSUNIT_TEST_BronsonAVLTreeMap
+            CDSUNIT_TEST_CuckooMap
 
             //CDSUNIT_TEST_MultiLevelHashMap // the test is not suitable
         CPPUNIT_TEST_SUITE_END();
 
         ////CDSUNIT_DECLARE_StripedMap
         ////CDSUNIT_DECLARE_RefinableMap
-        //CDSUNIT_DECLARE_CuckooMap
-        //CDSUNIT_DECLARE_MultiLevelHashMap
         ////CDSUNIT_DECLARE_StdMap
     };
 } // namespace map2
index 3d314b5f14ab1edf4a69ebc845db9b1beb2a7d29..72e5c2050bbbb3c16ea83026e0b384f384448e17 100644 (file)
@@ -3,10 +3,10 @@
 #include "map2/map_delodd.h"
 #include "map2/map_type_cuckoo.h"
 
-namespace map2 {
-    CDSUNIT_DEFINE_CuckooMap(cds::intrusive::cuckoo::implementation_tag, Map_DelOdd)
+#undef TEST_CASE
+#define TEST_CASE(TAG, X)  void Map_DelOdd::X() { run_test_no_extract<typename map_type< TAG, key_type, value_type>::X>(); }
+#include "map2/map_defs.h"
 
-    CPPUNIT_TEST_SUITE_PART( Map_DelOdd, run_CuckooMap )
-        CDSUNIT_TEST_CuckooMap
-    CPPUNIT_TEST_SUITE_END_PART()
+namespace map2 {
+    CDSUNIT_DECLARE_CuckooMap
 } // namespace map2
index 3875ead7937cafadb964b868dd96b8d28d9bd1e2..c99d8676f97e5f81b75f702577262aec43be47d6 100644 (file)
@@ -4,34 +4,42 @@
 #define CDSUNIT_MAP_TYPE_CUCKOO_H
 
 #include "map2/map_type.h"
-
 #include <cds/container/cuckoo_map.h>
-
 #include "print_cuckoo_stat.h"
 
 namespace map2 {
 
     template <typename K, typename V, typename Traits>
-    class CuckooMap :
-        public cc::CuckooMap< K, V, Traits >
+    class CuckooMap: public cc::CuckooMap< K, V, Traits >
     {
     public:
-        typedef cc::CuckooMap< K, V, Traits > cuckoo_base_class;
+        typedef cc::CuckooMap< K, V, Traits > base_class;
 
     public:
-        CuckooMap( size_t nCapacity, size_t nLoadFactor )
-            : cuckoo_base_class( nCapacity / (nLoadFactor * 16), (unsigned int) 4 )
+        template <typename Config>
+        CuckooMap( Config const& cfg )
+            : base_class( 
+                cfg.c_nCuckooInitialSize,
+                static_cast<unsigned int>( cfg.c_nCuckooProbesetSize ),
+                static_cast<unsigned int>( cfg.c_nCuckooProbesetThreshold )
+            )
         {}
 
         template <typename Q, typename Pred>
         bool erase_with( Q const& key, Pred /*pred*/ )
         {
-            return cuckoo_base_class::erase_with( key, typename std::conditional< cuckoo_base_class::c_isSorted, Pred, typename Pred::equal_to>::type() );
+            return base_class::erase_with( key, typename std::conditional< base_class::c_isSorted, Pred, typename Pred::equal_to>::type() );
         }
+
+        // for testing
+        static CDS_CONSTEXPR bool const c_bExtractSupported = false;
+        static CDS_CONSTEXPR bool const c_bLoadFactorDepended = false;
     };
 
+    struct tag_CuckooMap;
+
     template <typename Key, typename Value>
-    struct map_type< cds::intrusive::cuckoo::implementation_tag, Key, Value >: public map_type_base< Key, Value >
+    struct map_type< tag_CuckooMap, Key, Value >: public map_type_base< Key, Value >
     {
         typedef map_type_base< Key, Value > base_class;
         typedef typename base_class::compare    compare;
@@ -160,7 +168,7 @@ namespace map2 {
     static inline void print_stat( CuckooMap< K, V, Traits > const& m )
     {
         typedef CuckooMap< K, V, Traits > map_type;
-        print_stat( static_cast<typename map_type::cuckoo_base_class const&>(m) );
+        print_stat( static_cast<typename map_type::base_class const&>(m) );
     }
 
 }   // namespace map2
index 1d2fc9cf7c4853f77ae4ccd2a924b2f3b19ce16a..a8f0576206b87c1c740ea6321ec9095a6d168379 100644 (file)
@@ -63,11 +63,11 @@ namespace std {
             << "\t\t           m_nInsertResizeCount: " << s.m_nInsertResizeCount.get()              << "\n"
             << "\t\t         m_nInsertRelocateCount: " << s.m_nInsertRelocateCount.get()            << "\n"
             << "\t\t         m_nInsertRelocateFault: " << s.m_nInsertRelocateFault.get()            << "\n"
-            << "\t\t            m_nEnsureExistCount: " << s.m_nEnsureExistCount.get()               << "\n"
-            << "\t\t          m_nEnsureSuccessCount: " << s.m_nEnsureSuccessCount.get()             << "\n"
-            << "\t\t           m_nEnsureResizeCount: " << s.m_nEnsureResizeCount.get()              << "\n"
-            << "\t\t         m_nEnsureRelocateCount: " << s.m_nEnsureRelocateCount.get()            << "\n"
-            << "\t\t         m_nEnsureRelocateFault: " << s.m_nEnsureRelocateFault.get()            << "\n"
+            << "\t\t            m_nUpdateExistCount: " << s.m_nUpdateExistCount.get()               << "\n"
+            << "\t\t          m_nUpdateSuccessCount: " << s.m_nUpdateSuccessCount.get()             << "\n"
+            << "\t\t           m_nUpdateResizeCount: " << s.m_nUpdateResizeCount.get()              << "\n"
+            << "\t\t         m_nUpdateRelocateCount: " << s.m_nUpdateRelocateCount.get()            << "\n"
+            << "\t\t         m_nUpdateRelocateFault: " << s.m_nUpdateRelocateFault.get()            << "\n"
             << "\t\t               m_nUnlinkSuccess: " << s.m_nUnlinkSuccess.get()                  << "\n"
             << "\t\t                m_nUnlinkFailed: " << s.m_nUnlinkFailed.get()                   << "\n"
             << "\t\t                m_nEraseSuccess: " << s.m_nEraseSuccess.get()                   << "\n"