Fixed -Wshadow warnings
[libcds.git] / cds / container / cuckoo_set.h
index 741330144c164fb5c5dd1fc7232df64a82671109..d29bf8d619b09954be36929ce55e8c106baf76b4 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_CUCKOO_SET_H
 #define CDSLIB_CONTAINER_CUCKOO_SET_H
@@ -89,7 +117,7 @@ namespace cds { namespace container {
         <b>About Cuckoo hashing</b>
 
             [From "The Art of Multiprocessor Programming"]
-            Cuckoo hashing is a hashing algorithm in which a newly added item displaces any earlier item
+            <a href="https://en.wikipedia.org/wiki/Cuckoo_hashing">Cuckoo hashing</a> is a hashing algorithm in which a newly added item displaces any earlier item
             occupying the same slot. For brevity, a table is a k-entry array of items. For a hash set f size
             N = 2k we use a two-entry array of tables, and two independent hash functions,
             <tt> h0, h1: KeyRange -> 0,...,k-1</tt>
@@ -127,9 +155,9 @@ namespace cds { namespace container {
             the average search complexity is <tt>O(PROBE_SET/2)</tt>.
             However, the overhead of sorting can eliminate a gain of ordered search.
 
-            The probe set is ordered if opt::compare or opt::less is specified in \p %CuckooSet
-            declaration. Otherwise, the probe set is unordered and \p %CuckooSet must contain
-            opt::equal_to option.
+            The probe set is ordered if \p compare or \p less is specified in \p Traits
+            template parameter. Otherwise, the probe set is unordered and \p Traits must contain
+            \p equal_to predicate.
 
         Template arguments:
         - \p T - the type stored in the set.
@@ -345,10 +373,6 @@ namespace cds { namespace container {
         /// item counter type
         typedef typename traits::item_counter  item_counter;
 
-        //@cond
-        typedef cds::container::cuckoo::implementation_tag implementation_tag;
-        //@endcond
-
     protected:
         //@cond
         typedef typename base_class::value_type         node_type;
@@ -450,7 +474,7 @@ namespace cds { namespace container {
         CuckooSet(
             hash_tuple_type&& h     ///< hash functor tuple of type <tt>std::tuple<H1, H2, ... Hn></tt> where <tt> n == \ref c_nArity </tt>
         )
-        : base_class( std::forward<hash_tuple_type>(h) )
+        : base_class( std::forward<hash_tuple_type>(h))
         {}
 
         /// Constructs the set object with given probe set properties and hash functor tuple (move semantics)
@@ -464,7 +488,7 @@ namespace cds { namespace container {
             , unsigned int nProbesetThreshold   ///< probe set threshold, <tt>nProbesetThreshold < nProbesetSize</tt>. If 0, nProbesetThreshold = nProbesetSize - 1
             , hash_tuple_type&& h    ///< hash functor tuple of type <tt>std::tuple<H1, H2, ... Hn></tt> where <tt> n == \ref c_nArity </tt>
         )
-        : base_class( nInitialSize, nProbesetSize, nProbesetThreshold, std::forward<hash_tuple_type>(h) )
+        : base_class( nInitialSize, nProbesetSize, nProbesetThreshold, std::forward<hash_tuple_type>(h))
         {}
 
         /// Destructor clears the set
@@ -555,7 +579,7 @@ namespace cds { namespace container {
             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.
 
-            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.
@@ -614,7 +638,7 @@ namespace cds { namespace container {
         bool erase_with( Q const& key, Predicate pred )
         {
             CDS_UNUSED( pred );
-            node_type * pNode = base_class::erase_with( key, typename maker::template predicate_wrapper<Predicate, bool>() );
+            node_type * pNode = base_class::erase_with( key, typename maker::template predicate_wrapper<Predicate, bool>());
             if ( pNode ) {
                 free_node( pNode );
                 return true;
@@ -661,7 +685,7 @@ namespace cds { namespace container {
         bool erase_with( Q const& key, Predicate pred, Func f )
         {
             CDS_UNUSED( pred );
-            node_type * pNode = base_class::erase_with( key, typename maker::template predicate_wrapper<Predicate, bool>() );
+            node_type * pNode = base_class::erase_with( key, typename maker::template predicate_wrapper<Predicate, bool>());
             if ( pNode ) {
                 f( pNode->m_val );
                 free_node( pNode );
@@ -775,7 +799,7 @@ namespace cds { namespace container {
         */
         void clear()
         {
-            return base_class::clear_and_dispose( node_disposer() );
+            return base_class::clear_and_dispose( node_disposer());
         }
 
         /// Checks if the set is empty