node_type * pCur ; // guarded by guards; needed only for *ensure* function
};
-
-# ifndef CDS_CXX11_LAMBDA_SUPPORT
- struct empty_insert_functor {
- void operator()( value_type& )
- {}
- };
-
- struct empty_erase_functor {
- void operator()( value_type const& )
- {}
- };
-
- struct empty_find_functor {
- template <typename Q>
- void operator()( value_type& item, Q& val )
- {}
- };
-
- struct get_functor {
- typename gc::Guard& m_guard;
-
- get_functor( typename gc::Guard& gp )
- : m_guard(gp)
- {}
-
- template <typename Q>
- void operator()( value_type& item, Q& val )
- {
- m_guard.assign( &item );
- }
- };
-
- template <typename Func>
- struct insert_at_ensure_functor {
- Func m_func;
- insert_at_ensure_functor( Func f ) : m_func(f) {}
-
- void operator()( value_type& item )
- {
- cds::unref( m_func)( true, item, item );
- }
- };
-
- struct copy_value_functor {
- template <typename Q>
- void operator()( Q& dest, value_type const& src ) const
- {
- dest = src;
- }
- };
-
- struct dummy_copy_functor {
- template <typename Q>
- void operator()( Q&, value_type const&) const {}
- };
-# endif // ifndef CDS_CXX11_LAMBDA_SUPPORT
-
//@endcond
protected:
template <typename Q, typename Compare>
bool get_with_( typename gc::Guard& guard, Q const& val, Compare cmp )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return find_with_( val, cmp, [&guard](value_type& found, Q const& ) { guard.assign(&found); } );
-# else
- get_functor gf(guard);
- return find_with_( val, cmp, cds::ref(gf) );
-# endif
}
template <typename Q, typename Compare, typename Func>
assert( cmp( *node_traits::to_value_ptr( pDel ), val ) == 0 );
unsigned int nHeight = pDel->height();
- if ( try_remove_at( pDel, pos,
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
- [](value_type const&) {}
-# else
- empty_erase_functor()
-# endif
- ))
- {
+ if ( try_remove_at( pDel, pos, [](value_type const&) {} )) {
--m_ItemCounter;
m_Stat.onRemoveNode( nHeight );
m_Stat.onExtractSuccess();
unsigned int nHeight = pDel->height();
gDel.assign( node_traits::to_value_ptr(pDel) );
- if ( try_remove_at( pDel, pos,
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
- [](value_type const&) {}
-# else
- empty_erase_functor()
-# endif
- ))
- {
+ if ( try_remove_at( pDel, pos, [](value_type const&) {} )) {
--m_ItemCounter;
m_Stat.onRemoveNode( nHeight );
m_Stat.onExtractMinSuccess();
unsigned int nHeight = pDel->height();
gDel.assign( node_traits::to_value_ptr(pDel) );
- if ( try_remove_at( pDel, pos,
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
- [](value_type const&) {}
-# else
- empty_erase_functor()
-# endif
- ))
- {
+ if ( try_remove_at( pDel, pos, [](value_type const&) {} )) {
--m_ItemCounter;
m_Stat.onRemoveNode( nHeight );
m_Stat.onExtractMaxSuccess();
*/
bool insert( value_type& val )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return insert( val, []( value_type& ) {} );
-# else
- return insert( val, empty_insert_functor() );
-# endif
}
/// Inserts new node
bool bTowerOk = nHeight > 1 && pNode->get_tower() != nullptr;
bool bTowerMade = false;
-# ifndef CDS_CXX11_LAMBDA_SUPPORT
- insert_at_ensure_functor<Func> wrapper( func );
-# endif
-
position pos;
while ( true )
{
bTowerOk = true;
}
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
- if ( !insert_at_position( val, pNode, pos, [&func]( value_type& item ) { cds::unref(func)( true, item, item ); }))
-# else
- if ( !insert_at_position( val, pNode, pos, cds::ref(wrapper) ))
-# endif
- {
+ if ( !insert_at_position( val, pNode, pos, [&func]( value_type& item ) { cds::unref(func)( true, item, item ); })) {
m_Stat.onInsertRetry();
continue;
}
typename gc::Guard gDel;
gDel.assign( node_traits::to_value_ptr(pDel) );
- if ( node_traits::to_value_ptr( pDel ) == &val && try_remove_at( pDel, pos,
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
- [](value_type const&) {}
-# else
- empty_erase_functor()
-# endif
- ))
- {
+ if ( node_traits::to_value_ptr( pDel ) == &val && try_remove_at( pDel, pos, [](value_type const&) {} )) {
--m_ItemCounter;
m_Stat.onRemoveNode( nHeight );
m_Stat.onUnlinkSuccess();
template <typename Q>
bool erase( Q const& val )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return erase_( val, key_comparator(), [](value_type const&) {} );
-# else
- return erase_( val, key_comparator(), empty_erase_functor() );
-# endif
}
/// Deletes the item from the set with comparing functor \p pred
template <typename Q, typename Less>
bool erase_with( Q const& val, Less pred )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return erase_( val, cds::opt::details::make_comparator_from_less<Less>(), [](value_type const&) {} );
-# else
- return erase_( val, cds::opt::details::make_comparator_from_less<Less>(), empty_erase_functor() );
-# endif
}
/// Deletes the item from the set
template <typename Q>
bool find( Q const & val )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return find_with_( val, key_comparator(), [](value_type& , Q const& ) {} );
-# else
- return find_with_( val, key_comparator(), empty_find_functor() );
-# endif
}
/// Finds the key \p val with comparing functor \p pred
template <typename Q, typename Less>
bool find_with( Q const& val, Less pred )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return find_with_( val, cds::opt::details::make_comparator_from_less<Less>(), [](value_type& , Q const& ) {} );
-# else
- return find_with_( val, cds::opt::details::make_comparator_from_less<Less>(), empty_find_functor() );
-# endif
}
/// Finds the key \p val and return the item found