Merge branch 'check' into dev
[libcds.git] / cds / container / impl / ellen_bintree_set.h
index 6c8290c83051140cd5d6c52ef5eb60bd0aad6ef4..410a70d2098a4f4812954fb493cf3290631e9310 100644 (file)
@@ -334,71 +334,79 @@ namespace cds { namespace container {
 
         /// 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 minimum value.
-            If the set is empty, the function returns \p false, \p result is left unchanged.
+            If the set is not empty, the function returns a guarded pointer to minimum value.
+            If the set is empty, the function returns an empty \p guarded_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.
             During unlinking, a concurrent thread may insert an item with key less than leftmost item's key.
             So, the function returns the item with minimum key at the moment of tree traversing.
 
-            The guarded pointer \p dest prevents deallocation of returned item,
-            see cds::gc::guarded_ptr for explanation.
+            The guarded pointer prevents deallocation of returned item,
+            see \p cds::gc::guarded_ptr for explanation.
             @note Each \p guarded_ptr object uses the GC's guard that can be limited resource.
         */
-        bool extract_min( guarded_ptr& result )
+        guarded_ptr extract_min()
         {
-            return base_class::extract_min_( result.guard() );
+            guarded_ptr gp;
+            base_class::extract_min_( gp.guard() );
+            return gp;
         }
 
         /// 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 maximal value.
-            If the set is empty, the function returns \p false, \p result is left unchanged.
+            If the set is not empty, the function returns a guarded pointer to maximal value.
+            If the set is empty, the function returns an empty \p guarded_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.
             During unlinking, a concurrent thread may insert an item with key great than leftmost item's key.
             So, the function returns the item with maximum key at the moment of tree traversing.
 
-            The guarded pointer \p dest prevents deallocation of returned item,
-            see cds::gc::guarded_ptr for explanation.
+            The guarded pointer prevents deallocation of returned item,
+            see \p cds::gc::guarded_ptr for explanation.
             @note Each \p guarded_ptr object uses the GC's guard that can be limited resource.
         */
-        bool extract_max( guarded_ptr& result )
+        guarded_ptr extract_max()
         {
-            return base_class::extract_max_( result.guard() );
+            guarded_ptr gp;
+            base_class::extract_max_( gp.guard() );
+            return gp;
         }
 
         /// Extracts an item from the tree
         /** \anchor cds_nonintrusive_EllenBinTreeSet_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 the item  is not found the function returns \p false.
+            unlinks it, and returns an guarded pointer to it.
+            If the item  is not found the function returns an empty \p guarded_ptr.
 
-            The guarded pointer \p dest prevents deallocation of returned item,
-            see cds::gc::guarded_ptr for explanation.
+            The guarded pointer prevents deallocation of returned item,
+            see \p cds::gc::guarded_ptr for explanation.
             @note Each \p guarded_ptr object uses the GC's guard that can be limited resource.
         */
         template <typename Q>
-        bool extract( guarded_ptr& result, Q const& key )
+        guarded_ptr extract( Q const& key )
         {
-            return base_class::extract_( result.guard(), key );
+            guarded_ptr gp;
+            base_class::extract_( gp.guard(), key );
+            return gp;
         }
 
         /// Extracts an item from the set using \p pred for searching
         /**
-            The function is an analog of \ref cds_nonintrusive_EllenBinTreeSet_extract "extract(guarded_ptr& dest, Q const&)"
+            The function is an analog of \ref cds_nonintrusive_EllenBinTreeSet_extract "extract(Q const&)"
             but \p pred is used for key compare.
             \p Less has the interface like \p std::less.
             \p pred must imply the same element order as the comparator used for building the set.
         */
         template <typename Q, typename Less>
-        bool extract_with( guarded_ptr& result, Q const& key, Less pred )
+        guarded_ptr extract_with( Q const& key, Less pred )
         {
             CDS_UNUSED( pred );
-            return base_class::extract_with_( result.guard(), key,
+            guarded_ptr gp;
+            base_class::extract_with_( gp.guard(), key,
                 cds::details::predicate_wrapper< leaf_node, Less, typename maker::value_accessor >());
+            return gp;
         }
 
         /// Find the key \p key
@@ -495,32 +503,36 @@ namespace cds { namespace container {
 
         /// Finds \p key and returns the item found
         /** @anchor cds_nonintrusive_EllenBinTreeSet_get
-            The function searches the item with key equal to \p key and returns the item found in \p result parameter.
+            The function searches the item with key equal to \p key and returns the item found as an guarded pointer.
             The function returns \p true if \p key is found, \p false otherwise.
 
-            The guarded pointer \p dest prevents deallocation of returned item,
-            see cds::gc::guarded_ptr for explanation.
+            The guarded pointer prevents deallocation of returned item,
+            see \p cds::gc::guarded_ptr for explanation.
             @note Each \p guarded_ptr object uses the GC's guard that can be limited resource.
         */
         template <typename Q>
-        bool get( guarded_ptr& result, Q const& key )
+        guarded_ptr get( Q const& key )
         {
-            return base_class::get_( result.guard(), key );
+            guarded_ptr gp;
+            base_class::get_( gp.guard(), key );
+            return gp;
         }
 
         /// Finds \p key with predicate \p pred and returns the item found
         /**
-            The function is an analog of \ref cds_nonintrusive_EllenBinTreeSet_get "get(guarded_ptr&, Q const&)"
+            The function is an analog of \ref cds_nonintrusive_EllenBinTreeSet_get "get(Q const&)"
             but \p pred is used for key comparing.
             \p Less functor has the interface like \p std::less.
             \p pred must imply the same element order as the comparator used for building the set.
         */
         template <typename Q, typename Less>
-        bool get_with( guarded_ptr& result, Q const& key, Less pred )
+        guarded_ptr get_with( Q const& key, Less pred )
         {
-            CDS_UNUSED( pred );
-            return base_class::get_with_( result.guard(), key,
+            CDS_UNUSED(pred);
+            guarded_ptr gp;
+            base_class::get_with_( gp.guard(), key,
                 cds::details::predicate_wrapper< leaf_node, Less, typename maker::value_accessor >() );
+            return gp;
         }
 
         /// Clears the set (not atomic)