-//$$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
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>
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;
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 );
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 );
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;
}
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;