Bronson's AVL-tree impl
[libcds.git] / cds / container / ellen_bintree_set_rcu.h
index 4c802c931750d6f28ab6197a6ebc6df75e61afc2..eaa413552bb91ad05b92f1c100e1b5e4d38c25f0 100644 (file)
@@ -1,7 +1,7 @@
 //$$CDS-header$$
 
-#ifndef __CDS_CONTAINER_ELLEN_BINTREE_SET_RCU_H
-#define __CDS_CONTAINER_ELLEN_BINTREE_SET_RCU_H
+#ifndef CDSLIB_CONTAINER_ELLEN_BINTREE_SET_RCU_H
+#define CDSLIB_CONTAINER_ELLEN_BINTREE_SET_RCU_H
 
 #include <cds/container/details/ellen_bintree_base.h>
 #include <cds/intrusive/ellen_bintree_rcu.h>
@@ -145,9 +145,9 @@ namespace cds { namespace container {
         typedef typename gc::scoped_lock    rcu_lock;  ///< RCU scoped lock
 
         /// pointer to extracted node
-        typedef cds::urcu::exempt_ptr< gc, leaf_node, value_type, typename maker::intrusive_traits::disposer,
-            cds::urcu::details::conventional_exempt_member_cast<leaf_node, value_type>
-        > exempt_ptr;
+        using exempt_ptr = cds::urcu::exempt_ptr < gc, leaf_node, value_type, typename maker::intrusive_traits::disposer,
+            cds::urcu::details::conventional_exempt_member_cast < leaf_node, value_type >
+        >;
 
     public:
         /// Default constructor
@@ -196,7 +196,7 @@ namespace cds { namespace container {
             \endcode
             where \p val is the item inserted. User-defined functor \p f should guarantee that during changing
             \p val no any other changes could be made on this set's item by concurrent threads.
-            The user-defined functor is called only if the inserting is success. 
+            The user-defined functor is called only if the inserting is success.
 
             RCU \p synchronize() can be called. RCU should not be locked.
         */
@@ -298,6 +298,7 @@ namespace cds { namespace container {
         template <typename Q, typename Less>
         bool erase_with( Q const& key, Less pred )
         {
+            CDS_UNUSED( pred );
             return base_class::erase_with( key, cds::details::predicate_wrapper< leaf_node, Less, typename maker::value_accessor >());
         }
 
@@ -341,14 +342,15 @@ namespace cds { namespace container {
         template <typename Q, typename Less, typename Func>
         bool erase_with( Q const& key, Less pred, Func f )
         {
+            CDS_UNUSED( pred );
             return base_class::erase_with( key, cds::details::predicate_wrapper< leaf_node, Less, typename maker::value_accessor >(),
                 [&f]( leaf_node const& node) { f( node.m_Value ); } );
         }
 
         /// Extracts an item with minimal key from the set
         /**
-            If the set is not empty, the function returns \p true, \p result contains a pointer to value.
-            If the set is empty, the function returns \p false, \p result is left unchanged.
+            Returns \ref cds::urcu::exempt_ptr "exempt_ptr" pointer to the leftmost item.
+            If the set is empty, returns empty \p exempt_ptr.
 
             @note Due the concurrent nature of the set, the function extracts <i>nearly</i> minimum key.
             It means that the function gets leftmost leaf of the tree and tries to unlink it.
@@ -357,19 +359,18 @@ namespace cds { namespace container {
 
             RCU \p synchronize method can be called. RCU should NOT be locked.
             The function does not free the item.
-            The deallocator will be implicitly invoked when \p result object is destroyed or when
-            <tt>result.release()</tt> is called, see cds::urcu::exempt_ptr for explanation.
-            @note Before reusing \p result object you should call its \p release() method.
+            The deallocator will be implicitly invoked when the returned object is destroyed or when
+            its \p release() member function is called.
         */
-        bool extract_min( exempt_ptr& result )
+        exempt_ptr extract_min()
         {
-            return base_class::extract_min_( result );
+            return exempt_ptr( base_class::extract_min_());
         }
 
         /// Extracts an item with maximal key from the set
         /**
-            If the set is not empty, the function returns \p true, \p result contains a pointer to extracted item.
-            If the set is empty, the function returns \p false, \p result is left unchanged.
+            Returns \ref cds::urcu::exempt_ptr "exempt_ptr" pointer to the rightmost item.
+            If the set is empty, returns empty \p exempt_ptr.
 
             @note Due the concurrent nature of the set, the function extracts <i>nearly</i> maximal key.
             It means that the function gets rightmost leaf of the tree and tries to unlink it.
@@ -378,46 +379,44 @@ namespace cds { namespace container {
 
             RCU \p synchronize method can be called. RCU should NOT be locked.
             The function does not free the item.
-            The deallocator will be implicitly invoked when \p result object is destroyed or when
-            <tt>result.release()</tt> is called, see cds::urcu::exempt_ptr for explanation.
-            @note Before reusing \p result object you should call its \p release() method.
+            The deallocator will be implicitly invoked when the returned object is destroyed or when
+            its \p release() member function is called.
         */
-        bool extract_max( exempt_ptr& result )
+        exempt_ptr extract_max()
         {
-            return base_class::extract_max_( result );
+            return exempt_ptr( base_class::extract_max_());
         }
 
         /// Extracts an item from the set
         /** \anchor cds_nonintrusive_EllenBinTreeSet_rcu_extract
             The function searches an item with key equal to \p key in the tree,
-            unlinks it, and returns pointer to an item found in \p result parameter.
-            If \p key is not found the function returns \p false.
+            unlinks it, and returns \ref cds::urcu::exempt_ptr "exempt_ptr" pointer to an item found.
+            If \p key is not found the function returns an empty \p exempt_ptr.
 
             RCU \p synchronize method can be called. RCU should NOT be locked.
             The function does not destroy the item found.
-            The dealloctor will be implicitly invoked when \p result object is destroyed or when
-            <tt>result.release()</tt> is called, see cds::urcu::exempt_ptr for explanation.
-            @note Before reusing \p result object you should call its \p release() method.
+            The dealloctor will be implicitly invoked when the returned object is destroyed or when
+            its release() member function is called.
         */
         template <typename Q>
-        bool extract( exempt_ptr& result, Q const& key )
+        exempt_ptr extract( Q const& key )
         {
-            return base_class::extract_( result, key, typename base_class::node_compare());
+            return exempt_ptr( base_class::extract_( key, typename base_class::node_compare()));
         }
 
         /// Extracts an item from the set using \p pred for searching
         /**
-            The function is an analog of \ref cds_nonintrusive_EllenBinTreeSet_rcu_extract "extract(exempt_ptr&, Q const&)"
-            but \p pred is used for key compare.
+            The function is an analog of \p extract(Q const&) but \p pred is used for key compare.
             \p Less has the interface like \p std::less and should meet \ref cds_container_EllenBinTreeSet_rcu_less
             "predicate requirements".
             \p pred must imply the same element order as the comparator used for building the set.
         */
         template <typename Q, typename Less>
-        bool extract_with( exempt_ptr& result,  Q const& val, Less pred )
+        exempt_ptr extract_with( Q const& key, Less pred )
         {
-            return base_class::extract_with_( result, val,
-                cds::details::predicate_wrapper< leaf_node, Less, typename maker::value_accessor >() );
+            CDS_UNUSED( pred );
+            return exempt_ptr( base_class::extract_with_( key,
+                cds::details::predicate_wrapper< leaf_node, Less, typename maker::value_accessor >() ));
         }
 
         /// Find the key \p key
@@ -471,6 +470,7 @@ namespace cds { namespace container {
         template <typename Q, typename Less, typename Func>
         bool find_with( Q& key, Less pred, Func f ) const
         {
+            CDS_UNUSED( pred );
             return base_class::find_with( key, cds::details::predicate_wrapper< leaf_node, Less, typename maker::value_accessor >(),
                 [&f]( leaf_node& node, Q& v ) { f( node.m_Value, v ); } );
         }
@@ -478,6 +478,7 @@ namespace cds { namespace container {
         template <typename Q, typename Less, typename Func>
         bool find_with( Q const& key, Less pred, Func f ) const
         {
+            CDS_UNUSED( pred );
             return base_class::find_with( key, cds::details::predicate_wrapper< leaf_node, Less, typename maker::value_accessor >(),
                                           [&f]( leaf_node& node, Q const& v ) { f( node.m_Value, v ); } );
         }
@@ -510,6 +511,7 @@ namespace cds { namespace container {
         template <typename Q, typename Less>
         bool find_with( Q const& key, Less pred ) const
         {
+            CDS_UNUSED( pred );
             return base_class::find_with( key, cds::details::predicate_wrapper< leaf_node, Less, typename maker::value_accessor >());
         }
 
@@ -540,6 +542,7 @@ namespace cds { namespace container {
         template <typename Q, typename Less>
         value_type * get_with( Q const& key, Less pred ) const
         {
+            CDS_UNUSED( pred );
             leaf_node * pNode = base_class::get_with( key,
                 cds::details::predicate_wrapper< leaf_node, Less, typename maker::value_accessor >());
             return pNode ? &pNode->m_Value : nullptr;
@@ -602,4 +605,4 @@ namespace cds { namespace container {
     };
 }}  // namespace cds::container
 
-#endif // #ifndef __CDS_CONTAINER_ELLEN_BINTREE_SET_RCU_H
+#endif // #ifndef CDSLIB_CONTAINER_ELLEN_BINTREE_SET_RCU_H