Fixed -Wshadow warnings
[libcds.git] / cds / container / impl / ellen_bintree_set.h
index 381938fbdfc499c33af93facc00049b289f4c81b..5f93f4647771a7d6e605b85afc1de8cc29a2de9a 100644 (file)
@@ -1,4 +1,32 @@
-//$$CDS-header$$
+/*
+    This file is a part of libcds - Concurrent Data Structures library
+
+    (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2017
+
+    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 CDSLIB_CONTAINER_IMPL_ELLEN_BINTREE_SET_H
 #define CDSLIB_CONTAINER_IMPL_ELLEN_BINTREE_SET_H
@@ -32,7 +60,7 @@ namespace cds { namespace container {
         the priority value plus some uniformly distributed random value.
 
         @warning Recall the tree is <b>unbalanced</b>. The complexity of operations is <tt>O(log N)</tt>
-        for uniformly distributed random keys, but in worst case the complexity is <tt>O(N)</tt>.
+        for uniformly distributed random keys, but in the worst case the complexity is <tt>O(N)</tt>.
 
         @note In the current implementation we do not use helping technique described in the original paper.
         In Hazard Pointer schema helping is too complicated and does not give any observable benefits.
@@ -135,10 +163,6 @@ namespace cds { namespace container {
         typedef typename base_class::node_allocator         node_allocator;   ///< Internal node allocator
         typedef typename base_class::update_desc_allocator  update_desc_allocator; ///< Update descriptor allocator
 
-        //@cond
-        typedef cds::container::ellen_bintree::implementation_tag implementation_tag;
-        //@endcond
-
     protected:
         //@cond
         typedef typename maker::cxx_leaf_node_allocator cxx_leaf_node_allocator;
@@ -177,7 +201,7 @@ namespace cds { namespace container {
         bool insert( Q const& val )
         {
             scoped_node_ptr sp( cxx_leaf_node_allocator().New( val ));
-            if ( base_class::insert( *sp.get() )) {
+            if ( base_class::insert( *sp.get())) {
                 sp.release();
                 return true;
             }
@@ -203,7 +227,7 @@ namespace cds { namespace container {
         bool insert( Q const& val, Func f )
         {
             scoped_node_ptr sp( cxx_leaf_node_allocator().New( val ));
-            if ( base_class::insert( *sp.get(), [&f]( leaf_node& val ) { f( val.m_Value ); } )) {
+            if ( base_class::insert( *sp.get(), [&f]( leaf_node& v ) { f( v.m_Value ); } )) {
                 sp.release();
                 return true;
             }
@@ -232,7 +256,7 @@ namespace cds { namespace container {
             The functor can change non-key fields of the \p item; however, \p func must guarantee
             that during changing no any other modifications could be made on this item by concurrent threads.
 
-            Returns std::pair<bool, bool> where \p first is \p true if operation is successfull,
+            Returns std::pair<bool, bool> where \p first is \p true if operation is successful,
             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.
@@ -251,8 +275,8 @@ namespace cds { namespace container {
             return bRes;
         }
         //@cond
-        // Deprecated, use update()
         template <typename Q, typename Func>
+        CDS_DEPRECATED("ensure() is deprecated, use update()")
         std::pair<bool, bool> ensure( const Q& val, Func func )
         {
             return update( val, func, true );
@@ -266,8 +290,8 @@ namespace cds { namespace container {
         template <typename... Args>
         bool emplace( Args&&... args )
         {
-            scoped_node_ptr sp( cxx_leaf_node_allocator().New( std::forward<Args>(args)... ));
-            if ( base_class::insert( *sp.get() )) {
+            scoped_node_ptr sp( cxx_leaf_node_allocator().MoveNew( std::forward<Args>(args)... ));
+            if ( base_class::insert( *sp.get())) {
                 sp.release();
                 return true;
             }
@@ -359,9 +383,7 @@ namespace cds { namespace container {
         */
         guarded_ptr extract_min()
         {
-            guarded_ptr gp;
-            base_class::extract_min_( gp.guard() );
-            return gp;
+            return guarded_ptr( base_class::extract_min_());
         }
 
         /// Extracts an item with maximal key from the set
@@ -380,9 +402,7 @@ namespace cds { namespace container {
         */
         guarded_ptr extract_max()
         {
-            guarded_ptr gp;
-            base_class::extract_max_( gp.guard() );
-            return gp;
+            return guarded_ptr( base_class::extract_max_());
         }
 
         /// Extracts an item from the tree
@@ -398,9 +418,7 @@ namespace cds { namespace container {
         template <typename Q>
         guarded_ptr extract( Q const& key )
         {
-            guarded_ptr gp;
-            base_class::extract_( gp.guard(), key );
-            return gp;
+            return base_class::extract_( key );
         }
 
         /// Extracts an item from the set using \p pred for searching
@@ -414,10 +432,8 @@ namespace cds { namespace container {
         guarded_ptr extract_with( Q const& key, Less pred )
         {
             CDS_UNUSED( pred );
-            guarded_ptr gp;
-            base_class::extract_with_( gp.guard(), key,
+            return base_class::extract_with_( key,
                 cds::details::predicate_wrapper< leaf_node, Less, typename maker::value_accessor >());
-            return gp;
         }
 
         /// Find the key \p key
@@ -494,8 +510,8 @@ namespace cds { namespace container {
             return base_class::contains( key );
         }
         //@cond
-        // Deprecated, use contains()
         template <typename Q>
+        CDS_DEPRECATED("deprecated, use contains()")
         bool find( Q const & key )
         {
             return contains( key );
@@ -515,8 +531,8 @@ namespace cds { namespace container {
             return base_class::contains( key, cds::details::predicate_wrapper< leaf_node, Less, typename maker::value_accessor >());
         }
         //@cond
-        // Deprecated, use contains()
         template <typename Q, typename Less>
+        CDS_DEPRECATED("deprecated, use contains()")
         bool find_with( Q const& key, Less pred )
         {
             return contains( key, pred );
@@ -535,9 +551,7 @@ namespace cds { namespace container {
         template <typename Q>
         guarded_ptr get( Q const& key )
         {
-            guarded_ptr gp;
-            base_class::get_( gp.guard(), key );
-            return gp;
+            return base_class::get_( key );
         }
 
         /// Finds \p key with predicate \p pred and returns the item found
@@ -551,10 +565,8 @@ namespace cds { namespace container {
         guarded_ptr get_with( Q const& key, Less pred )
         {
             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;
+            return base_class::get_with_( key,
+                cds::details::predicate_wrapper< leaf_node, Less, typename maker::value_accessor >());
         }
 
         /// Clears the set (not atomic)
@@ -564,7 +576,7 @@ namespace cds { namespace container {
             this sequence
             \code
             set.clear();
-            assert( set.empty() );
+            assert( set.empty());
             \endcode
             the assertion could be raised.