Removed redundant spaces
[libcds.git] / cds / intrusive / striped_set / adapter.h
index 67be8d43bceeeed7cd6a678c1f4f20166d03644e..cb1574aa4ea66161497ee7dd3f0e179e5e2b3102 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-2016
+
+    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_INTRUSIVE_STRIPED_SET_ADAPTER_H
 #define CDSLIB_INTRUSIVE_STRIPED_SET_ADAPTER_H
@@ -76,7 +104,7 @@ namespace cds { namespace intrusive {
 
                 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,
+                Returns <tt> std::pair<bool, bool> </tt> where \p first is true if operation is successful,
                 \p second is true if new item has been added or \p false if the item with \p val key
                 already exists.
                 <hr>
@@ -195,7 +223,7 @@ namespace cds { namespace intrusive {
                 typedef typename container_type::iterator       iterator        ;   ///< container iterator
                 typedef typename container_type::const_iterator const_iterator  ;   ///< container const iterator
 
-                typedef typename container_type::value_compare  key_comparator;
+                typedef typename container_type::key_compare  key_comparator;
 
             private:
                 container_type  m_Set;
@@ -227,8 +255,8 @@ namespace cds { namespace intrusive {
                         return std::make_pair( true, res.second );
                     }
                     else {
-                        auto it = m_Set.find( val );
-                        if ( it == m_Set.end() )
+                        auto it = m_Set.find( val, key_comparator());
+                        if ( it == m_Set.end())
                             return std::make_pair( false, false );
                         f( false, *it, val );
                         return std::make_pair( true, false );
@@ -237,7 +265,7 @@ namespace cds { namespace intrusive {
 
                 bool unlink( value_type& val )
                 {
-                    iterator it = m_Set.find( value_type(val) );
+                    iterator it = m_Set.find( val, key_comparator());
                     if ( it == m_Set.end() || &(*it) != &val )
                         return false;
                     m_Set.erase( it );
@@ -247,7 +275,7 @@ namespace cds { namespace intrusive {
                 template <typename Q, typename Func>
                 value_type * erase( Q const& key, Func f )
                 {
-                    iterator it = m_Set.find( key, key_comparator() );
+                    iterator it = m_Set.find( key, key_comparator());
                     if (it == m_Set.end())
                         return nullptr;
                     value_type& val = *it;
@@ -269,16 +297,16 @@ namespace cds { namespace intrusive {
                 }
 
                 template <typename Q, typename Func>
-                bool find( Q& key, Func f )
+                bool find( Q const& key, Func f )
                 {
                     return find( key, key_comparator(), f );
                 }
 
                 template <typename Q, typename Compare, typename Func>
-                bool find( Q& key, Compare cmp, Func f )
+                bool find( Q const& key, Compare cmp, Func f )
                 {
                     iterator it = m_Set.find( key, cmp );
-                    if ( it == m_Set.end() )
+                    if ( it == m_Set.end())
                         return false;
                     f( *it, key );
                     return true;