// C++11 inline namespace
#define CDS_CXX11_INLINE_NAMESPACE_SUPPORT
-// Lambda
-#define CDS_CXX11_LAMBDA_SUPPORT
-
#define CDS_CONSTEXPR constexpr
#define CDS_CONSTEXPR_CONST constexpr const
/*
Required C++11 features:
- move semantics [CDS_RVALUE_SUPPORT, CDS_MOVE_SEMANTICS_SUPPORT]
+ - lambda function [CDS_CXX11_LAMBDA_SUPPORT]
- variadic template [CDS_CXX11_VARIADIC_TEMPLATE_SUPPORT]
- template alias [CDS_CXX11_TEMPLATE_ALIAS_SUPPORT]
- explicit conversion operator [CDS_CXX11_EXPLICIT_CONVERSION_OPERATOR_SUPPORT]
// C++11 inline namespace
#define CDS_CXX11_INLINE_NAMESPACE_SUPPORT
-// Lambda
-#define CDS_CXX11_LAMBDA_SUPPORT
-
// constexpr
#define CDS_CONSTEXPR constexpr
#define CDS_NOEXCEPT_SUPPORT noexcept
#define CDS_NOEXCEPT_SUPPORT_(expr) noexcept(expr)
-// Lambda (ICL 12 +)
-#define CDS_CXX11_LAMBDA_SUPPORT
-
// C++11 inline namespace
#define CDS_CXX11_INLINE_NAMESPACE_SUPPORT
#define CDS_NOEXCEPT_SUPPORT
#define CDS_NOEXCEPT_SUPPORT_(expr)
-// Lambda (VC 10 +)
-#define CDS_CXX11_LAMBDA_SUPPORT
-
// C++11 inline namespace
//#define CDS_CXX11_INLINE_NAMESPACE_SUPPORT
typedef std::unique_ptr< node_type, node_disposer > scoped_node_ptr;
-#ifndef CDS_CXX11_LAMBDA_SUPPORT
- struct empty_insert_functor
- {
- void operator()( value_type& ) const
- {}
- };
-
- template <typename Q>
- class insert_value_functor
- {
- Q const& m_val;
- public:
- insert_value_functor( Q const & v)
- : m_val(v)
- {}
-
- void operator()( value_type& item )
- {
- item.second = m_val;
- }
- };
-
- template <typename Func>
- class insert_key_wrapper: protected cds::details::functor_wrapper<Func>
- {
- typedef cds::details::functor_wrapper<Func> base_class;
- public:
- insert_key_wrapper( Func f ): base_class(f) {}
-
- void operator()( node_type& item )
- {
- base_class::get()( item.m_val );
- }
- };
-
- template <typename Func>
- class ensure_wrapper: protected cds::details::functor_wrapper<Func>
- {
- typedef cds::details::functor_wrapper<Func> base_class;
- public:
- ensure_wrapper( Func f) : base_class(f) {}
-
- void operator()( bool bNew, node_type& item, node_type const& )
- {
- base_class::get()( bNew, item.m_val );
- }
- };
-
- template <typename Func>
- class find_wrapper: protected cds::details::functor_wrapper<Func>
- {
- typedef cds::details::functor_wrapper<Func> base_class;
- public:
- find_wrapper( Func f )
- : base_class(f)
- {}
-
- template <typename Q>
- void operator()( node_type& item, Q& val )
- {
- base_class::get()( item.m_val, val );
- }
- };
-#endif // #ifndef CDS_CXX11_LAMBDA_SUPPORT
-
//@endcond
public:
template <typename K>
bool insert( K const& key )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return insert_key( key, [](value_type&){} );
-# else
- return insert_key( key, empty_insert_functor() );
-# endif
}
/// Inserts new node
template <typename K, typename V>
bool insert( K const& key, V const& val )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return insert_key( key, [&val](value_type& item) { item.second = val ; } );
-# else
- insert_value_functor<V> f(val);
- return insert_key( key, cds::ref(f) );
-# endif
}
/// Inserts new node and initialize it by a functor
bool insert_key( const K& key, Func func )
{
scoped_node_ptr pNode( alloc_node( key ));
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
- if ( base_class::insert( *pNode, [&func]( node_type& item ) { cds::unref(func)( item.m_val ); } ))
-# else
- insert_key_wrapper<Func> wrapper(func);
- if ( base_class::insert( *pNode, cds::ref(wrapper) ))
-#endif
- {
+ if ( base_class::insert( *pNode, [&func]( node_type& item ) { cds::unref(func)( item.m_val ); } )) {
pNode.release();
return true;
}
std::pair<bool, bool> ensure( K const& key, Func func )
{
scoped_node_ptr pNode( alloc_node( key ));
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
std::pair<bool, bool> res = base_class::ensure( *pNode,
[&func](bool bNew, node_type& item, node_type const& ){ cds::unref(func)( bNew, item.m_val ); }
);
-# else
- ensure_wrapper<Func> wrapper( func );
- std::pair<bool, bool> res = base_class::ensure( *pNode, cds::ref(wrapper) );
-# endif
if ( res.first && res.second )
pNode.release();
return res;
template <typename K, typename Func>
bool find( K const& key, Func f )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return base_class::find( key, [&f](node_type& item, K const& ) { cds::unref(f)( item.m_val );});
-# else
- find_wrapper<Func> wrapper(f);
- return base_class::find( key, cds::ref(wrapper) );
-# endif
}
/// Find the key \p val using \p pred predicate for comparing
template <typename K, typename Predicate, typename Func>
bool find_with( K const& key, Predicate pred, Func f )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return base_class::find_with( key, cds::details::predicate_wrapper<node_type, Predicate, key_accessor>(),
[&f](node_type& item, K const& ) { cds::unref(f)( item.m_val );});
-# else
- find_wrapper<Func> wrapper(f);
- return base_class::find_with( key, cds::details::predicate_wrapper<node_type, Predicate, key_accessor>(), cds::ref(wrapper) );
-# endif
}
/// Find the key \p key
typedef std::unique_ptr< node_type, node_disposer > scoped_node_ptr;
-# ifndef CDS_CXX11_LAMBDA_SUPPORT
- struct empty_insert_functor {
- void operator()( value_type& ) const
- {}
- };
-
- struct empty_find_functor {
- template <typename Q>
- void operator()( node_type& item, Q& val ) const
- {}
- };
-
- template <typename Func>
- class insert_wrapper: protected cds::details::functor_wrapper<Func>
- {
- typedef cds::details::functor_wrapper<Func> base_class;
- public:
- insert_wrapper( Func f ): base_class(f) {}
-
- void operator()( node_type& node )
- {
- base_class::get()( node.m_val );
- }
- };
-
- template <typename Q, typename Func>
- class ensure_wrapper: protected cds::details::functor_wrapper<Func>
- {
- typedef cds::details::functor_wrapper<Func> base_class;
- public:
- Q const& val;
-
- ensure_wrapper( Q const& v, Func f) : base_class(f), val(v) {}
-
- void operator()( bool bNew, node_type& item, node_type const& )
- {
- base_class::get()( bNew, item.m_val, val );
- }
- };
-
- template <typename Func>
- class find_wrapper: protected cds::details::functor_wrapper<Func>
- {
- typedef cds::details::functor_wrapper<Func> base_class;
- public:
- find_wrapper( Func f )
- : base_class(f)
- {}
-
- template <typename Q>
- void operator()( node_type& item, Q& val )
- {
- base_class::get()( item.m_val, val );
- }
- };
-# endif
//@endcond
public:
template <typename Q>
bool insert( Q const& val )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return insert( val, []( value_type& ) {} );
-# else
- return insert( val, empty_insert_functor() );
-# endif
}
/// Inserts new node
bool insert( Q const& val, Func f )
{
scoped_node_ptr pNode( alloc_node( val ));
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
- if ( base_class::insert( *pNode, [&f]( node_type& node ) { cds::unref(f)( node.m_val ); } ))
-# else
- insert_wrapper<Func> wrapper( f );
- if ( base_class::insert( *pNode, cds::ref(wrapper) ))
-# endif
- {
+ if ( base_class::insert( *pNode, [&f]( node_type& node ) { cds::unref(f)( node.m_val ); } )) {
pNode.release();
return true;
}
std::pair<bool, bool> ensure( Q const& val, Func func )
{
scoped_node_ptr pNode( alloc_node( val ));
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
std::pair<bool, bool> res = base_class::ensure( *pNode,
[&val,&func](bool bNew, node_type& item, node_type const& ){ cds::unref(func)( bNew, item.m_val, val ); }
);
-# else
- ensure_wrapper<Q, Func> wrapper( val, func );
- std::pair<bool, bool> res = base_class::ensure( *pNode, cds::ref(wrapper) );
-# endif
if ( res.first && res.second )
pNode.release();
return res;
template <typename Q, typename Func>
bool find( Q& val, Func f )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return base_class::find( val, [&f](node_type& item, Q& v) { cds::unref(f)( item.m_val, v );});
-# else
- find_wrapper<Func> wrapper(f);
- return base_class::find( val, cds::ref(wrapper) );
-# endif
}
/// Find the key \p val using \p pred predicate for comparing
template <typename Q, typename Predicate, typename Func>
bool find_with( Q& val, Predicate pred, Func f )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return base_class::find_with( val, typename maker::template predicate_wrapper<Predicate, bool>(),
[&f](node_type& item, Q& v) { cds::unref(f)( item.m_val, v );});
-# else
- find_wrapper<Func> wrapper(f);
- return base_class::find_with( val, typename maker::template predicate_wrapper<Predicate, bool>(), cds::ref(wrapper) );
-# endif
}
/// Find the key \p val
template <typename Q, typename Func>
bool find( Q const& val, Func f )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return base_class::find( val, [&f](node_type& item, Q const& v) { cds::unref(f)( item.m_val, v );});
-# else
- find_wrapper<Func> wrapper(f);
- return base_class::find( val, cds::ref(wrapper) );
-# endif
}
/// Find the key \p val using \p pred predicate for comparing
template <typename Q, typename Predicate, typename Func>
bool find_with( Q const& val, Predicate pred, Func f )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return base_class::find_with( val, typename maker::template predicate_wrapper<Predicate, bool>(),
[&f](node_type& item, Q const& v) { cds::unref(f)( item.m_val, v );});
-# else
- find_wrapper<Func> wrapper(f);
- return base_class::find_with( val, typename maker::template predicate_wrapper<Predicate, bool>(), cds::ref(wrapper) );
-# endif
}
/// Find the key \p val
template <typename Q>
bool find( Q const& val )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return base_class::find( val, [](node_type&, Q const&) {});
-# else
- return base_class::find( val, empty_find_functor());
-# endif
}
/// Find the key \p val using \p pred predicate for comparing
template <typename Q, typename Predicate>
bool find_with( Q const& val, Predicate pred )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return base_class::find_with( val, typename maker::template predicate_wrapper<Predicate, bool>(), [](node_type&, Q const&) {});
-# else
- return base_class::find_with( val, typename maker::template predicate_wrapper<Predicate, bool>(), empty_find_functor());
-# endif
}
/// Clears the set
/// Guarded pointer
typedef cds::gc::guarded_ptr< gc, leaf_node, value_type, details::guarded_ptr_cast_set<leaf_node, value_type> > guarded_ptr;
- protected:
- //@cond
-# ifndef CDS_CXX11_LAMBDA_SUPPORT
- struct empty_insert_functor
- {
- void operator()( value_type& ) const
- {}
- };
-
- template <typename Q>
- class insert_value_functor
- {
- Q const& m_val;
- public:
- insert_value_functor( Q const& v)
- : m_val(v)
- {}
-
- void operator()( value_type& item )
- {
- item.second = m_val;
- }
- };
-
- template <typename Func>
- class insert_key_wrapper: protected cds::details::functor_wrapper<Func>
- {
- typedef cds::details::functor_wrapper<Func> base_class;
- public:
- insert_key_wrapper( Func f ): base_class(f) {}
-
- void operator()( leaf_node& item )
- {
- base_class::get()( item.m_Value );
- }
- };
-
- template <typename Func>
- class ensure_wrapper: protected cds::details::functor_wrapper<Func>
- {
- typedef cds::details::functor_wrapper<Func> base_class;
- public:
- ensure_wrapper( Func f) : base_class(f) {}
-
- void operator()( bool bNew, leaf_node& item, leaf_node const& )
- {
- base_class::get()( bNew, item.m_Value );
- }
- };
-
- template <typename Func>
- struct erase_functor
- {
- Func m_func;
-
- erase_functor( Func f )
- : m_func(f)
- {}
-
- void operator()( leaf_node& node )
- {
- cds::unref(m_func)( node.m_Value );
- }
- };
-
- template <typename Func>
- class find_wrapper: protected cds::details::functor_wrapper<Func>
- {
- typedef cds::details::functor_wrapper<Func> base_class;
- public:
- find_wrapper( Func f )
- : base_class(f)
- {}
-
- template <typename Q>
- void operator()( leaf_node& item, Q& val )
- {
- base_class::get()( item.m_Value, val );
- }
- };
-# endif
- //@endcond
-
public:
/// Default constructor
EllenBinTreeMap()
template <typename K>
bool insert( K const& key )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return insert_key( key, [](value_type&){} );
-# else
- return insert_key( key, empty_insert_functor() );
-# endif
}
/// Inserts new node
bool insert_key( const K& key, Func func )
{
scoped_node_ptr pNode( cxx_leaf_node_allocator().New( key ));
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
- if ( base_class::insert( *pNode, [&func]( leaf_node& item ) { cds::unref(func)( item.m_Value ); } ))
-# else
- insert_key_wrapper<Func> wrapper(func);
- if ( base_class::insert( *pNode, cds::ref(wrapper) ))
-#endif
- {
+ if ( base_class::insert( *pNode, [&func]( leaf_node& item ) { cds::unref(func)( item.m_Value ); } )) {
pNode.release();
return true;
}
std::pair<bool, bool> ensure( K const& key, Func func )
{
scoped_node_ptr pNode( cxx_leaf_node_allocator().New( key ));
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
std::pair<bool, bool> res = base_class::ensure( *pNode,
[&func](bool bNew, leaf_node& item, leaf_node const& ){ cds::unref(func)( bNew, item.m_Value ); }
);
-# else
- ensure_wrapper<Func> wrapper( func );
- std::pair<bool, bool> res = base_class::ensure( *pNode, cds::ref(wrapper) );
-# endif
if ( res.first && res.second )
pNode.release();
return res;
template <typename K, typename Func>
bool erase( K const& key, Func f )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return base_class::erase( key, [&f]( leaf_node& node) { cds::unref(f)( node.m_Value ); } );
-# else
- erase_functor<Func> wrapper(f);
- return base_class::erase( key, cds::ref(wrapper));
-# endif
}
/// Deletes the item from the map using \p pred predicate for searching
template <typename K, typename Less, typename Func>
bool erase_with( K const& key, Less pred, Func f )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return base_class::erase_with( key, cds::details::predicate_wrapper< leaf_node, Less, typename maker::key_accessor >(),
[&f]( leaf_node& node) { cds::unref(f)( node.m_Value ); } );
-# else
- erase_functor<Func> wrapper(f);
- return base_class::erase_with( key, cds::details::predicate_wrapper< leaf_node, Less, typename maker::key_accessor >(), cds::ref(wrapper));
-# endif
}
/// Extracts an item with minimal key from the map
template <typename K, typename Func>
bool find( K const& key, Func f )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return base_class::find( key, [&f](leaf_node& item, K const& ) { cds::unref(f)( item.m_Value );});
-# else
- find_wrapper<Func> wrapper(f);
- return base_class::find( key, cds::ref(wrapper) );
-# endif
}
/// Finds the key \p val using \p pred predicate for searching
template <typename K, typename Less, typename Func>
bool find_with( K const& key, Less pred, Func f )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return base_class::find_with( key, cds::details::predicate_wrapper< leaf_node, Less, typename maker::key_accessor >(),
[&f](leaf_node& item, K const& ) { cds::unref(f)( item.m_Value );});
-# else
- find_wrapper<Func> wrapper(f);
- return base_class::find_with( key, cds::details::predicate_wrapper< leaf_node, Less, typename maker::key_accessor >(), cds::ref(wrapper) );
-# endif
}
/// Find the key \p key
cds::urcu::details::conventional_exempt_member_cast<leaf_node, value_type>
> exempt_ptr;
- protected:
- //@cond
-# ifndef CDS_CXX11_LAMBDA_SUPPORT
- struct empty_insert_functor
- {
- void operator()( value_type& ) const
- {}
- };
-
- template <typename Q>
- class insert_value_functor
- {
- Q const& m_val;
- public:
- insert_value_functor( Q const& v)
- : m_val(v)
- {}
-
- void operator()( value_type& item )
- {
- item.second = m_val;
- }
- };
-
- template <typename Func>
- class insert_key_wrapper: protected cds::details::functor_wrapper<Func>
- {
- typedef cds::details::functor_wrapper<Func> base_class;
- public:
- insert_key_wrapper( Func f ): base_class(f) {}
-
- void operator()( leaf_node& item )
- {
- base_class::get()( item.m_Value );
- }
- };
-
- template <typename Func>
- class ensure_wrapper: protected cds::details::functor_wrapper<Func>
- {
- typedef cds::details::functor_wrapper<Func> base_class;
- public:
- ensure_wrapper( Func f) : base_class(f) {}
-
- void operator()( bool bNew, leaf_node& item, leaf_node const& )
- {
- base_class::get()( bNew, item.m_Value );
- }
- };
-
- template <typename Func>
- struct erase_functor
- {
- Func m_func;
-
- erase_functor( Func f )
- : m_func(f)
- {}
-
- void operator()( leaf_node& node )
- {
- cds::unref(m_func)( node.m_Value );
- }
- };
-
- template <typename Func>
- class find_wrapper: protected cds::details::functor_wrapper<Func>
- {
- typedef cds::details::functor_wrapper<Func> base_class;
- public:
- find_wrapper( Func f )
- : base_class(f)
- {}
-
- template <typename Q>
- void operator()( leaf_node& item, Q& val )
- {
- base_class::get()( item.m_Value, val );
- }
- };
-# endif
- //@endcond
-
public:
/// Default constructor
EllenBinTreeMap()
template <typename K>
bool insert( K const& key )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return insert_key( key, [](value_type&){} );
-# else
- return insert_key( key, empty_insert_functor() );
-# endif
}
/// Inserts new node
bool insert_key( const K& key, Func func )
{
scoped_node_ptr pNode( cxx_leaf_node_allocator().New( key ));
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
- if ( base_class::insert( *pNode, [&func]( leaf_node& item ) { cds::unref(func)( item.m_Value ); } ))
-# else
- insert_key_wrapper<Func> wrapper(func);
- if ( base_class::insert( *pNode, cds::ref(wrapper) ))
-#endif
- {
+ if ( base_class::insert( *pNode, [&func]( leaf_node& item ) { cds::unref(func)( item.m_Value ); } )) {
pNode.release();
return true;
}
std::pair<bool, bool> ensure( K const& key, Func func )
{
scoped_node_ptr pNode( cxx_leaf_node_allocator().New( key ));
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
std::pair<bool, bool> res = base_class::ensure( *pNode,
[&func](bool bNew, leaf_node& item, leaf_node const& ){ cds::unref(func)( bNew, item.m_Value ); }
);
-# else
- ensure_wrapper<Func> wrapper( func );
- std::pair<bool, bool> res = base_class::ensure( *pNode, cds::ref(wrapper) );
-# endif
if ( res.first && res.second )
pNode.release();
return res;
template <typename K, typename Func>
bool erase( K const& key, Func f )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return base_class::erase( key, [&f]( leaf_node& node) { cds::unref(f)( node.m_Value ); } );
-# else
- erase_functor<Func> wrapper(f);
- return base_class::erase( key, cds::ref(wrapper));
-# endif
}
/// Deletes the item from the map using \p pred predicate for searching
template <typename K, typename Less, typename Func>
bool erase_with( K const& key, Less pred, Func f )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return base_class::erase_with( key, cds::details::predicate_wrapper< leaf_node, Less, typename maker::key_accessor >(),
[&f]( leaf_node& node) { cds::unref(f)( node.m_Value ); } );
-# else
- erase_functor<Func> wrapper(f);
- return base_class::erase_with( key, cds::details::predicate_wrapper< leaf_node, Less, typename maker::key_accessor >(), cds::ref(wrapper));
-# endif
}
/// Extracts an item with minimal key from the map
template <typename K, typename Func>
bool find( K const& key, Func f )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return base_class::find( key, [&f](leaf_node& item, K const& ) { cds::unref(f)( item.m_Value );});
-# else
- find_wrapper<Func> wrapper(f);
- return base_class::find( key, cds::ref(wrapper) );
-# endif
}
/// Finds the key \p val using \p pred predicate for searching
template <typename K, typename Less, typename Func>
bool find_with( K const& key, Less pred, Func f )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return base_class::find_with( key, cds::details::predicate_wrapper< leaf_node, Less, typename maker::key_accessor >(),
[&f](leaf_node& item, K const& ) { cds::unref(f)( item.m_Value );});
-# else
- find_wrapper<Func> wrapper(f);
- return base_class::find_with( key, cds::details::predicate_wrapper< leaf_node, Less, typename maker::key_accessor >(), cds::ref(wrapper) );
-# endif
}
/// Find the key \p key
/// Guarded pointer
typedef cds::gc::guarded_ptr< gc, leaf_node, value_type, details::guarded_ptr_cast_set<leaf_node, value_type> > guarded_ptr;
- protected:
- //@cond
-# ifndef CDS_CXX11_LAMBDA_SUPPORT
- template <typename Func>
- struct insert_functor
- {
- Func m_func;
-
- insert_functor ( Func f )
- : m_func(f)
- {}
-
- void operator()( leaf_node& node )
- {
- cds::unref(m_func)( node.m_Value );
- }
- };
-
- template <typename Q, typename Func>
- struct ensure_functor
- {
- Func m_func;
- Q const& m_arg;
-
- ensure_functor( Q const& arg, Func f )
- : m_func(f)
- , m_arg( arg )
- {}
-
- void operator ()( bool bNew, leaf_node& node, leaf_node& )
- {
- cds::unref(m_func)( bNew, node.m_Value, m_arg );
- }
- };
-
- template <typename Func>
- struct erase_functor
- {
- Func m_func;
-
- erase_functor( Func f )
- : m_func(f)
- {}
-
- void operator()( leaf_node const& node )
- {
- cds::unref(m_func)( node.m_Value );
- }
- };
-
- template <typename Func>
- struct find_functor
- {
- Func m_func;
-
- find_functor( Func f )
- : m_func(f)
- {}
-
- template <typename Q>
- void operator ()( leaf_node& node, Q& val )
- {
- cds::unref(m_func)( node.m_Value, val );
- }
- };
-#endif
- //@endcond
-
public:
/// Default constructor
EllenBinTreeSet()
bool insert( Q const& val, Func f )
{
scoped_node_ptr sp( cxx_leaf_node_allocator().New( val ));
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
- if ( base_class::insert( *sp.get(), [&f]( leaf_node& val ) { cds::unref(f)( val.m_Value ); } ))
-# else
- insert_functor<Func> wrapper(f);
- if ( base_class::insert( *sp, cds::ref(wrapper) ))
-# endif
- {
+ if ( base_class::insert( *sp.get(), [&f]( leaf_node& val ) { cds::unref(f)( val.m_Value ); } )) {
sp.release();
return true;
}
std::pair<bool, bool> ensure( const Q& val, Func func )
{
scoped_node_ptr sp( cxx_leaf_node_allocator().New( val ));
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
std::pair<bool, bool> bRes = base_class::ensure( *sp,
[&func, &val](bool bNew, leaf_node& node, leaf_node&){ cds::unref(func)( bNew, node.m_Value, val ); });
-# else
- ensure_functor<Q, Func> wrapper( val, func );
- std::pair<bool, bool> bRes = base_class::ensure( *sp, cds::ref(wrapper));
-# endif
if ( bRes.first && bRes.second )
sp.release();
return bRes;
template <typename Q, typename Func>
bool erase( Q const& key, Func f )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return base_class::erase( key, [&f]( leaf_node const& node) { cds::unref(f)( node.m_Value ); } );
-# else
- erase_functor<Func> wrapper(f);
- return base_class::erase( key, cds::ref(wrapper));
-# endif
}
/// Deletes the item from the set using \p pred predicate for searching
template <typename Q, typename Less, typename Func>
bool erase_with( Q const& key, Less pred, Func f )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return base_class::erase_with( key, cds::details::predicate_wrapper< leaf_node, Less, typename maker::value_accessor >(),
[&f]( leaf_node const& node) { cds::unref(f)( node.m_Value ); } );
-# else
- erase_functor<Func> wrapper(f);
- return base_class::erase_with( key, cds::details::predicate_wrapper< leaf_node, Less, typename maker::value_accessor >(), cds::ref(wrapper));
-# endif
}
/// Extracts an item with minimal key from the set
template <typename Q, typename Func>
bool find( Q& val, Func f )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return base_class::find( val, [&f]( leaf_node& node, Q& v ) { cds::unref(f)( node.m_Value, v ); });
-# else
- find_functor<Func> wrapper(f);
- return base_class::find( val, cds::ref(wrapper));
-# endif
}
/// Finds the key \p val using \p pred predicate for searching
template <typename Q, typename Less, typename Func>
bool find_with( Q& val, Less pred, Func f )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return base_class::find_with( val, cds::details::predicate_wrapper< leaf_node, Less, typename maker::value_accessor >(),
[&f]( leaf_node& node, Q& v ) { cds::unref(f)( node.m_Value, v ); } );
-# else
- find_functor<Func> wrapper(f);
- return base_class::find_with( val, cds::details::predicate_wrapper< leaf_node, Less, typename maker::value_accessor >(),
- cds::ref(wrapper));
-# endif
}
/// Find the key \p val
template <typename Q, typename Func>
bool find( Q const& val, Func f )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return base_class::find( val, [&f]( leaf_node& node, Q const& v ) { cds::unref(f)( node.m_Value, v ); });
-# else
- find_functor<Func> wrapper(f);
- return base_class::find( val, cds::ref(wrapper));
-# endif
}
/// Finds the key \p val using \p pred predicate for searching
template <typename Q, typename Less, typename Func>
bool find_with( Q const& val, Less pred, Func f )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return base_class::find_with( val, cds::details::predicate_wrapper< leaf_node, Less, typename maker::value_accessor >(),
[&f]( leaf_node& node, Q const& v ) { cds::unref(f)( node.m_Value, v ); } );
-# else
- find_functor<Func> wrapper(f);
- return base_class::find_with( val, cds::details::predicate_wrapper< leaf_node, Less, typename maker::value_accessor >(),
- cds::ref(wrapper));
-# endif
}
/// Find the key \p val
cds::urcu::details::conventional_exempt_member_cast<leaf_node, value_type>
> exempt_ptr;
- protected:
- //@cond
-# ifndef CDS_CXX11_LAMBDA_SUPPORT
- template <typename Func>
- struct insert_functor
- {
- Func m_func;
-
- insert_functor ( Func f )
- : m_func(f)
- {}
-
- void operator()( leaf_node& node )
- {
- cds::unref(m_func)( node.m_Value );
- }
- };
-
- template <typename Q, typename Func>
- struct ensure_functor
- {
- Func m_func;
- Q const& m_arg;
-
- ensure_functor( Q const& arg, Func f )
- : m_func(f)
- , m_arg( arg )
- {}
-
- void operator ()( bool bNew, leaf_node& node, leaf_node& )
- {
- cds::unref(m_func)( bNew, node.m_Value, m_arg );
- }
- };
-
- template <typename Func>
- struct erase_functor
- {
- Func m_func;
-
- erase_functor( Func f )
- : m_func(f)
- {}
-
- void operator()( leaf_node const& node )
- {
- cds::unref(m_func)( node.m_Value );
- }
- };
-
- template <typename Func>
- struct find_functor
- {
- Func m_func;
-
- find_functor( Func f )
- : m_func(f)
- {}
-
- template <typename Q>
- void operator ()( leaf_node& node, Q& val )
- {
- cds::unref(m_func)( node.m_Value, val );
- }
- };
-#endif
- //@endcond
-
public:
/// Default constructor
EllenBinTreeSet()
bool insert( Q const& val, Func f )
{
scoped_node_ptr sp( cxx_leaf_node_allocator().New( val ));
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
- if ( base_class::insert( *sp.get(), [&f]( leaf_node& val ) { cds::unref(f)( val.m_Value ); } ))
-# else
- insert_functor<Func> wrapper(f);
- if ( base_class::insert( *sp, cds::ref(wrapper) ))
-# endif
- {
+ if ( base_class::insert( *sp.get(), [&f]( leaf_node& val ) { cds::unref(f)( val.m_Value ); } )) {
sp.release();
return true;
}
std::pair<bool, bool> ensure( const Q& val, Func func )
{
scoped_node_ptr sp( cxx_leaf_node_allocator().New( val ));
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
std::pair<bool, bool> bRes = base_class::ensure( *sp,
[&func, &val](bool bNew, leaf_node& node, leaf_node&){ cds::unref(func)( bNew, node.m_Value, val ); });
-# else
- ensure_functor<Q, Func> wrapper( val, func );
- std::pair<bool, bool> bRes = base_class::ensure( *sp, cds::ref(wrapper));
-# endif
if ( bRes.first && bRes.second )
sp.release();
return bRes;
template <typename Q, typename Func>
bool erase( Q const& key, Func f )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return base_class::erase( key, [&f]( leaf_node const& node) { cds::unref(f)( node.m_Value ); } );
-# else
- erase_functor<Func> wrapper(f);
- return base_class::erase( key, cds::ref(wrapper));
-# endif
}
/// Deletes the item from the set using \p pred predicate for searching
template <typename Q, typename Less, typename Func>
bool erase_with( Q const& key, Less pred, Func f )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return base_class::erase_with( key, cds::details::predicate_wrapper< leaf_node, Less, typename maker::value_accessor >(),
[&f]( leaf_node const& node) { cds::unref(f)( node.m_Value ); } );
-# else
- erase_functor<Func> wrapper(f);
- return base_class::erase_with( key, cds::details::predicate_wrapper< leaf_node, Less, typename maker::value_accessor >(), cds::ref(wrapper));
-# endif
}
/// Extracts an item with minimal key from the set
template <typename Q, typename Func>
bool find( Q& val, Func f ) const
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return base_class::find( val, [&f]( leaf_node& node, Q& v ) { cds::unref(f)( node.m_Value, v ); });
-# else
- find_functor<Func> wrapper(f);
- return base_class::find( val, cds::ref(wrapper));
-# endif
}
/// Finds the key \p val using \p pred predicate for searching
template <typename Q, typename Less, typename Func>
bool find_with( Q& val, Less pred, Func f ) const
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return base_class::find_with( val, cds::details::predicate_wrapper< leaf_node, Less, typename maker::value_accessor >(),
[&f]( leaf_node& node, Q& v ) { cds::unref(f)( node.m_Value, v ); } );
-# else
- find_functor<Func> wrapper(f);
- return base_class::find_with( val, cds::details::predicate_wrapper< leaf_node, Less, typename maker::value_accessor >(),
- cds::ref(wrapper));
-# endif
}
/// Find the key \p val
template <typename Q, typename Func>
bool find( Q const& val, Func f ) const
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return base_class::find( val, [&f]( leaf_node& node, Q const& v ) { cds::unref(f)( node.m_Value, v ); });
-# else
- find_functor<Func> wrapper(f);
- return base_class::find( val, cds::ref(wrapper));
-# endif
}
/// Finds the key \p val using \p pred predicate for searching
template <typename Q, typename Less, typename Func>
bool find_with( Q const& val, Less pred, Func f ) const
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return base_class::find_with( val, cds::details::predicate_wrapper< leaf_node, Less, typename maker::value_accessor >(),
[&f]( leaf_node& node, Q const& v ) { cds::unref(f)( node.m_Value, v ); } );
-# else
- find_functor<Func> wrapper(f);
- return base_class::find_with( val, cds::details::predicate_wrapper< leaf_node, Less, typename maker::value_accessor >(),
- cds::ref(wrapper));
-# endif
}
/// Find the key \p val
/// Guarded pointer
typedef cds::gc::guarded_ptr< gc, node_type, value_type, details::guarded_ptr_cast_map<node_type, value_type> > guarded_ptr;
- private:
- //@cond
-# ifndef CDS_CXX11_LAMBDA_SUPPORT
- template <typename Func>
- class insert_functor: protected cds::details::functor_wrapper<Func>
- {
- typedef cds::details::functor_wrapper<Func> base_class;
- public:
- insert_functor ( Func f )
- : base_class( f )
- {}
-
- void operator()( node_type& node )
- {
- base_class::get()( node.m_Data );
- }
- };
-
- template <typename Func>
- class ensure_functor: protected cds::details::functor_wrapper<Func>
- {
- typedef cds::details::functor_wrapper<Func> base_class;
- public:
- ensure_functor( Func f )
- : base_class(f)
- {}
-
- void operator ()( bool bNew, node_type& node, node_type& )
- {
- base_class::get()( bNew, node.m_Data );
- }
- };
-
- template <typename Func>
- class find_functor: protected cds::details::functor_wrapper<Func>
- {
- typedef cds::details::functor_wrapper<Func> base_class;
- public:
- find_functor( Func f )
- : base_class(f)
- {}
-
- template <typename Q>
- void operator ()( node_type& node, Q& )
- {
- base_class::get()( node.m_Data );
- }
- };
-
- template <typename Func>
- struct erase_functor
- {
- Func m_func;
-
- erase_functor( Func f )
- : m_func( f )
- {}
-
- void operator ()( node_type const & node )
- {
- cds::unref(m_func)( const_cast<value_type&>(node.m_Data) );
- }
- };
-# endif // ifndef CDS_CXX11_LAMBDA_SUPPORT
- //@endcond
-
protected:
//@cond
template <typename K>
{
scoped_node_ptr pNode( alloc_node( key ));
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
- if ( base_class::insert_at( &refHead, *pNode, [&f](node_type& node){ cds::unref(f)( node.m_Data ); } ))
-# else
- insert_functor<Func> wrapper( f );
- if ( base_class::insert_at( &refHead, *pNode, cds::ref(wrapper) ))
-# endif
- {
+ if ( base_class::insert_at( &refHead, *pNode, [&f](node_type& node){ cds::unref(f)( node.m_Data ); } )) {
pNode.release();
return true;
}
template <typename K, typename Compare, typename Func>
bool erase_at( head_type& refHead, K const& key, Compare cmp, Func f )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return base_class::erase_at( &refHead, key, cmp, [&f](node_type const & node){cds::unref(f)( const_cast<value_type&>(node.m_Data)); });
-# else
- erase_functor<Func> wrapper( f );
- return base_class::erase_at( &refHead, key, cmp, cds::ref(wrapper) );
-# endif
}
template <typename K, typename Compare>
{
scoped_node_ptr pNode( alloc_node( key ));
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
std::pair<bool, bool> ret = base_class::ensure_at( &refHead, *pNode,
[&f]( bool bNew, node_type& node, node_type& ){ cds::unref(f)( bNew, node.m_Data ); });
-# else
- ensure_functor<Func> wrapper( f );
- std::pair<bool, bool> ret = base_class::ensure_at( &refHead, *pNode, cds::ref(wrapper));
-# endif
if ( ret.first && ret.second )
pNode.release();
template <typename K, typename Compare, typename Func>
bool find_at( head_type& refHead, K& key, Compare cmp, Func f )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return base_class::find_at( &refHead, key, cmp, [&f]( node_type& node, K& ){ cds::unref(f)( node.m_Data ); });
-# else
- find_functor<Func> wrapper( f );
- return base_class::find_at( &refHead, key, cmp, cds::ref(wrapper) );
-# endif
}
template <typename K, typename Compare>
typedef typename base_class::node_type head_type;
//@endcond
- private:
- //@cond
-# ifndef CDS_CXX11_LAMBDA_SUPPORT
- struct ensure_functor
- {
- node_type * m_pItemFound;
-
- ensure_functor()
- : m_pItemFound( nullptr )
- {}
-
- void operator ()(bool, node_type& item, node_type& )
- {
- m_pItemFound = &item;
- }
- };
-
- template <typename Func>
- class find_functor: protected cds::details::functor_wrapper<Func>
- {
- typedef cds::details::functor_wrapper<Func> base_class;
- public:
- find_functor( Func f )
- : base_class(f)
- {}
-
- template <typename Q>
- void operator ()( node_type& node, Q& )
- {
- base_class::get()( node.m_Data );
- }
- };
-# endif // ifndef CDS_CXX11_LAMBDA_SUPPORT
- //@endcond
-
protected:
//@cond
template <typename K>
scoped_node_ptr pNode( alloc_node( key ));
node_type * pItemFound = nullptr;
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
std::pair<bool, bool> ret = base_class::ensure_at( &refHead, *pNode, [&pItemFound](bool, node_type& item, node_type&){ pItemFound = &item; } );
-# else
- ensure_functor func;
- std::pair<bool, bool> ret = base_class::ensure_at( &refHead, *pNode, boost::ref(func) );
- pItemFound = func.m_pItemFound;
-# endif
if ( ret.first && ret.second )
pNode.release();
template <typename K, typenam Compare, typename Func>
bool find_at( head_type& refHead, K& key, Compare cmp, Func f )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return base_class::find_at( &refHead, key, cmp, [&f]( node_type& node, K const& ){ cds::unref(f)( node.m_Data ); });
-# else
- find_functor<Func> wrapper( f );
- return base_class::find_at( &refHead, key, cmp, cds::ref(wrapper) );
-# endif
}
*/
//@endcond
cds::urcu::details::conventional_exempt_pair_cast<node_type, value_type>
> exempt_ptr;
- private:
- //@cond
-# ifndef CDS_CXX11_LAMBDA_SUPPORT
- template <typename Func>
- class insert_functor: protected cds::details::functor_wrapper<Func>
- {
- typedef cds::details::functor_wrapper<Func> base_class;
- public:
- insert_functor ( Func f )
- : base_class( f )
- {}
-
- void operator()( node_type& node )
- {
- base_class::get()( node.m_Data );
- }
- };
-
- template <typename Func>
- class ensure_functor: protected cds::details::functor_wrapper<Func>
- {
- typedef cds::details::functor_wrapper<Func> base_class;
- public:
- ensure_functor( Func f )
- : base_class(f)
- {}
-
- void operator ()( bool bNew, node_type& node, node_type& )
- {
- base_class::get()( bNew, node.m_Data );
- }
- };
-
- template <typename Func>
- class find_functor: protected cds::details::functor_wrapper<Func>
- {
- typedef cds::details::functor_wrapper<Func> base_class;
- public:
- find_functor( Func f )
- : base_class(f)
- {}
-
- template <typename Q>
- void operator ()( node_type& node, Q& )
- {
- base_class::get()( node.m_Data );
- }
- };
-
- struct empty_find_functor
- {
- template <typename Q>
- void operator ()( node_type& node, Q& val ) const
- {}
- };
-
- template <typename Func>
- struct erase_functor
- {
- Func m_func;
-
- erase_functor( Func f )
- : m_func( f )
- {}
-
- void operator ()( node_type const & node )
- {
- cds::unref(m_func)( const_cast<value_type&>(node.m_Data) );
- }
- };
-# endif // ifndef CDS_CXX11_LAMBDA_SUPPORT
- //@endcond
-
protected:
//@cond
template <typename K>
{
scoped_node_ptr pNode( alloc_node( key ));
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
- if ( base_class::insert_at( &refHead, *pNode, [&f](node_type& node){ cds::unref(f)( node.m_Data ); } ))
-# else
- insert_functor<Func> wrapper( f );
- if ( base_class::insert_at( &refHead, *pNode, cds::ref(wrapper) ))
-# endif
- {
+ if ( base_class::insert_at( &refHead, *pNode, [&f](node_type& node){ cds::unref(f)( node.m_Data ); } )) {
pNode.release();
return true;
}
template <typename K, typename Compare, typename Func>
bool erase_at( head_type& refHead, K const & key, Compare cmp, Func f )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return base_class::erase_at( &refHead, key, cmp, [&f](node_type const & node){cds::unref(f)( const_cast<value_type&>(node.m_Data)); });
-# else
- erase_functor<Func> wrapper( f );
- return base_class::erase_at( &refHead, key, cmp, cds::ref(wrapper) );
-# endif
}
template <typename K, typename Func>
{
scoped_node_ptr pNode( alloc_node( key ));
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
std::pair<bool, bool> ret = base_class::ensure_at( &refHead, *pNode,
[&f]( bool bNew, node_type& node, node_type& ){ cds::unref(f)( bNew, node.m_Data ); });
-# else
- ensure_functor<Func> wrapper( f );
- std::pair<bool, bool> ret = base_class::ensure_at( &refHead, *pNode, cds::ref(wrapper));
-# endif
if ( ret.first && ret.second )
pNode.release();
template <typename K, typename Compare>
bool find_at( head_type& refHead, K const& key, Compare cmp ) const
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return base_class::find_at( &refHead, key, cmp, [](node_type&, K const&) {} );
-# else
- return base_class::find_at( &refHead, key, cmp, empty_find_functor() );
-# endif
}
template <typename K, typename Compare, typename Func>
bool find_at( head_type& refHead, K& key, Compare cmp, Func f ) const
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return base_class::find_at( &refHead, key, cmp, [&f]( node_type& node, K& ){ cds::unref(f)( node.m_Data ); });
-# else
- find_functor<Func> wrapper( f );
- return base_class::find_at( &refHead, key, cmp, cds::ref(wrapper) );
-# endif
}
template <typename K, typename Compare>
typedef typename options::type_traits::compare intrusive_key_comparator;
typedef typename base_class::node_type head_type;
-# ifndef CDS_CXX11_LAMBDA_SUPPORT
- typedef typename base_class::empty_erase_functor empty_erase_functor;
-# endif
//@endcond
public:
{
return n.m_Value;
}
-
-# ifndef CDS_CXX11_LAMBDA_SUPPORT
- template <typename Func>
- struct insert_functor
- {
- Func m_func;
-
- insert_functor ( Func f )
- : m_func(f)
- {}
-
- void operator()( node_type& node )
- {
- cds::unref(m_func)( node_to_value(node) );
- }
- };
-
- template <typename Q, typename Func>
- struct ensure_functor
- {
- Func m_func;
- const Q& m_arg;
-
- ensure_functor( const Q& arg, Func f )
- : m_func(f)
- , m_arg( arg )
- {}
-
- void operator ()( bool bNew, node_type& node, node_type& )
- {
- cds::unref(m_func)( bNew, node_to_value(node), m_arg );
- }
- };
-
- template <typename Func>
- struct find_functor
- {
- Func m_func;
-
- find_functor( Func f )
- : m_func(f)
- {}
-
- template <typename Q>
- void operator ()( node_type& node, Q& val )
- {
- cds::unref(m_func)( node_to_value(node), val );
- }
- };
-
- template <typename Func>
- struct erase_functor
- {
- Func m_func;
-
- erase_functor( Func f )
- : m_func(f)
- {}
-
- void operator()( node_type const& node )
- {
- cds::unref(m_func)( node_to_value(node) );
- }
- };
-# endif // ifndef CDS_CXX11_LAMBDA_SUPPORT
//@endcond
protected:
template <typename Q>
bool erase( Q const& key )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return erase_at( head(), key, intrusive_key_comparator(), [](value_type const&){} );
-# else
- return erase_at( head(), key, intrusive_key_comparator(), empty_erase_functor() );
-# endif
}
/// Deletes the item from the list using \p pred predicate for searching
template <typename Q, typename Less>
bool erase_with( Q const& key, Less pred )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return erase_at( head(), key, typename options::template less_wrapper<Less>::type(), [](value_type const&){} );
-# else
- return erase_at( head(), key, typename options::template less_wrapper<Less>::type(), empty_erase_functor() );
-# endif
}
/// Deletes \p key from the list
{
scoped_node_ptr pNode( alloc_node( key ));
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
-# ifdef CDS_BUG_STATIC_MEMBER_IN_LAMBDA
- // GCC 4.5-4.7: node_to_value is unaccessible from lambda,
- // like as MichaelList::node_to_value that requires to capture *this* despite on node_to_value is static function
- value_type& (* n2v)( node_type& ) = node_to_value;
- if ( base_class::insert_at( &refHead, *pNode, [&f,n2v](node_type& node){ cds::unref(f)( n2v(node) ); } ))
-# else
- if ( base_class::insert_at( &refHead, *pNode, [&f](node_type& node){ cds::unref(f)( node_to_value(node) ); } ))
-# endif
-# else
- insert_functor<Func> wrapper( f );
- if ( base_class::insert_at( &refHead, *pNode, cds::ref(wrapper) ))
-# endif
- {
+ if ( base_class::insert_at( &refHead, *pNode, [&f](node_type& node){ cds::unref(f)( node_to_value(node) ); } )) {
pNode.release();
return true;
}
template <typename Q, typename Compare, typename Func>
bool erase_at( head_type& refHead, const Q& key, Compare cmp, Func f )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
-# ifdef CDS_BUG_STATIC_MEMBER_IN_LAMBDA
- // GCC 4.5-4.7: node_to_value is unaccessible from lambda,
- // like as MichaelList::node_to_value that requires to capture *this* despite on node_to_value is static function
- value_type const& (* n2v)( node_type const& ) = node_to_value;
- return base_class::erase_at( &refHead, key, cmp, [&f,n2v](node_type const& node){ cds::unref(f)( n2v(node) ); } );
-# else
return base_class::erase_at( &refHead, key, cmp, [&f](node_type const& node){ cds::unref(f)( node_to_value(node) ); } );
-# endif
-# else
- erase_functor<Func> wrapper( f );
- return base_class::erase_at( &refHead, key, cmp, cds::ref(wrapper) );
-# endif
}
template <typename Q, typename Compare>
{
scoped_node_ptr pNode( alloc_node( key ));
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
-# ifdef CDS_BUG_STATIC_MEMBER_IN_LAMBDA
- // GCC 4.5-4.7: node_to_value is unaccessible from lambda,
- // like as MichaelList::node_to_value that requires to capture *this* despite on node_to_value is static function
- value_type& (* n2v)( node_type& ) = node_to_value;
- std::pair<bool, bool> ret = base_class::ensure_at( &refHead, *pNode,
- [&f, &key, n2v](bool bNew, node_type& node, node_type&){cds::unref(f)( bNew, n2v(node), key ); });
-# else
std::pair<bool, bool> ret = base_class::ensure_at( &refHead, *pNode,
[&f, &key](bool bNew, node_type& node, node_type&){cds::unref(f)( bNew, node_to_value(node), key ); });
-# endif
-# else
- ensure_functor<Q, Func> wrapper( key, f );
- std::pair<bool, bool> ret = base_class::ensure_at( &refHead, *pNode, cds::ref(wrapper));
-# endif
if ( ret.first && ret.second )
pNode.release();
template <typename Q, typename Compare, typename Func>
bool find_at( head_type& refHead, Q& val, Compare cmp, Func f )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
-# ifdef CDS_BUG_STATIC_MEMBER_IN_LAMBDA
- // GCC 4.5-4.7: node_to_value is unaccessible from lambda,
- // like as MichaelList::node_to_value that requires to capture *this* despite on node_to_value is static function
- value_type& (* n2v)( node_type& ) = node_to_value;
- return base_class::find_at( &refHead, val, cmp, [&f,n2v](node_type& node, Q& val){ cds::unref(f)( n2v(node), val ); });
-# else
return base_class::find_at( &refHead, val, cmp, [&f](node_type& node, Q& val){ cds::unref(f)( node_to_value(node), val ); });
-# endif
-# else
- find_functor<Func> wrapper( f );
- return base_class::find_at( &refHead, val, cmp, cds::ref(wrapper) );
-# endif
}
template <typename Q, typename Compare>
typedef typename base_class::node_type head_type;
//@endcond
- protected:
- //@cond
-# ifndef CDS_CXX11_LAMBDA_SUPPORT
- struct ensure_functor
- {
- node_type * m_pItemFound;
-
- ensure_functor()
- : m_pItemFound( nullptr )
- {}
-
- void operator ()(bool, node_type& item, node_type& )
- {
- m_pItemFound = &item;
- }
- };
-# endif
- //@endcond
-
protected:
//@cond
static node_type * alloc_node()
scoped_node_ptr pNode( alloc_node( val ));
node_type * pItemFound = nullptr;
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
std::pair<bool, bool> ret = base_class::ensure_at( &refHead, *pNode,
[&pItemFound](bool, node_type& item, node_type&){ pItemFound = &item; });
-# else
- ensure_functor func;
- std::pair<bool, bool> ret = base_class::ensure_at( &refHead, *pNode, boost::ref(func) );
- pItemFound = func.m_pItemFound;
-# endif
assert( pItemFound != nullptr );
if ( ret.first && ret.second )
typedef typename maker::type_traits::compare intrusive_key_comparator;
typedef typename base_class::node_type head_type;
-# ifndef CDS_CXX11_LAMBDA_SUPPORT
- typedef typename base_class::empty_erase_functor empty_erase_functor;
-# endif
//@endcond
public:
{
return n.m_Value;
}
-
-# ifndef CDS_CXX11_LAMBDA_SUPPORT
- template <typename Func>
- struct insert_functor
- {
- Func m_func;
-
- insert_functor ( Func f )
- : m_func(f)
- {}
-
- void operator()( node_type& node )
- {
- cds::unref(m_func)( node_to_value(node) );
- }
- };
-
- template <typename Q, typename Func>
- struct ensure_functor
- {
- Func m_func;
- Q const& m_arg;
-
- ensure_functor( Q const& arg, Func f )
- : m_func(f)
- , m_arg( arg )
- {}
-
- void operator ()( bool bNew, node_type& node, node_type& )
- {
- cds::unref(m_func)( bNew, node_to_value(node), m_arg );
- }
- };
-
- template <typename Func>
- struct find_functor
- {
- Func m_func;
-
- find_functor( Func f )
- : m_func(f)
- {}
-
- template <typename Q>
- void operator ()( node_type& node, Q& val )
- {
- cds::unref(m_func)( node_to_value(node), val );
- }
- };
-
- struct empty_find_functor
- {
- template <typename Q>
- void operator ()( node_type& node, Q& val ) const
- {}
- };
-
- template <typename Func>
- struct erase_functor
- {
- Func m_func;
-
- erase_functor( Func f )
- : m_func(f)
- {}
-
- void operator()( node_type const& node )
- {
- cds::unref(m_func)( node_to_value(node) );
- }
- };
-# endif // ifndef CDS_CXX11_LAMBDA_SUPPORT
//@endcond
protected:
template <typename Q>
bool erase( Q const& key )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return erase_at( head(), key, intrusive_key_comparator(), [](value_type const&){} );
-# else
- return erase_at( head(), key, intrusive_key_comparator(), empty_erase_functor() );
-# endif
}
/// Deletes the item from the list using \p pred predicate for searching
template <typename Q, typename Less>
bool erase_with( Q const& key, Less pred )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return erase_at( head(), key, typename maker::template less_wrapper<Less>::type(), [](value_type const&){} );
-# else
- return erase_at( head(), key, typename maker::template less_wrapper<Less>::type(), empty_erase_functor() );
-# endif
}
/// Deletes \p key from the list
{
scoped_node_ptr pNode( alloc_node( key ));
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
-# ifdef CDS_BUG_STATIC_MEMBER_IN_LAMBDA
- // GCC 4.5-4.7: node_to_value is unaccessible from lambda,
- // like as MichaelList::node_to_value that requires to capture *this* despite on node_to_value is static function
- value_type& (* n2v)( node_type& ) = node_to_value;
- if ( base_class::insert_at( &refHead, *pNode, [&f,n2v](node_type& node){ cds::unref(f)( n2v(node) ); } ))
-# else
- if ( base_class::insert_at( &refHead, *pNode, [&f](node_type& node){ cds::unref(f)( node_to_value(node) ); } ))
-# endif
-# else
- insert_functor<Func> wrapper( f );
- if ( base_class::insert_at( &refHead, *pNode, cds::ref(wrapper) ))
-# endif
- {
+ if ( base_class::insert_at( &refHead, *pNode, [&f](node_type& node){ cds::unref(f)( node_to_value(node) ); } )) {
pNode.release();
return true;
}
template <typename Q, typename Compare, typename Func>
bool erase_at( head_type& refHead, Q const& key, Compare cmp, Func f )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
-# ifdef CDS_BUG_STATIC_MEMBER_IN_LAMBDA
- // GCC 4.5-4.7: node_to_value is unaccessible from lambda,
- // like as MichaelList::node_to_value that requires to capture *this* despite on node_to_value is static function
- value_type const& (* n2v)( node_type const& ) = node_to_value;
- return base_class::erase_at( &refHead, key, cmp, [&f,n2v](node_type const& node){ cds::unref(f)( n2v(node) ); } );
-# else
return base_class::erase_at( &refHead, key, cmp, [&f](node_type const& node){ cds::unref(f)( node_to_value(node) ); } );
-# endif
-# else
- erase_functor<Func> wrapper( f );
- return base_class::erase_at( &refHead, key, cmp, cds::ref(wrapper) );
-# endif
}
template <typename Q, typename Compare>
{
scoped_node_ptr pNode( alloc_node( key ));
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
-# ifdef CDS_BUG_STATIC_MEMBER_IN_LAMBDA
- // GCC 4.5-4.7: node_to_value is unaccessible from lambda,
- // like as MichaelList::node_to_value that requires to capture *this* despite on node_to_value is static function
- value_type& (* n2v)( node_type& ) = node_to_value;
- std::pair<bool, bool> ret = base_class::ensure_at( &refHead, *pNode,
- [&f, &key, n2v](bool bNew, node_type& node, node_type&){cds::unref(f)( bNew, n2v(node), key ); });
-# else
std::pair<bool, bool> ret = base_class::ensure_at( &refHead, *pNode,
[&f, &key](bool bNew, node_type& node, node_type&){cds::unref(f)( bNew, node_to_value(node), key ); });
-# endif
-# else
- ensure_functor<Q, Func> wrapper( key, f );
- std::pair<bool, bool> ret = base_class::ensure_at( &refHead, *pNode, cds::ref(wrapper));
-# endif
if ( ret.first && ret.second )
pNode.release();
template <typename Q, typename Compare>
bool find_at( head_type& refHead, Q const& key, Compare cmp ) const
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return base_class::find_at( &refHead, key, cmp, [](node_type&, Q const &) {} );
-# else
- return base_class::find_at( &refHead, key, cmp, empty_find_functor() );
-# endif
}
template <typename Q, typename Compare, typename Func>
bool find_at( head_type& refHead, Q& val, Compare cmp, Func f ) const
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
-# ifdef CDS_BUG_STATIC_MEMBER_IN_LAMBDA
- // GCC 4.5-4.7: node_to_value is unaccessible from lambda,
- // like as MichaelList::node_to_value that requires to capture *this* despite on node_to_value is static function
- value_type& (* n2v)( node_type& ) = node_to_value;
- return base_class::find_at( &refHead, val, cmp, [&f,n2v](node_type& node, Q& val){ cds::unref(f)( n2v(node), val ); });
-# else
return base_class::find_at( &refHead, val, cmp, [&f](node_type& node, Q& val){ cds::unref(f)( node_to_value(node), val ); });
-# endif
-# else
- find_functor<Func> wrapper( f );
- return base_class::find_at( &refHead, val, cmp, cds::ref(wrapper) );
-# endif
}
template <typename Q, typename Compare>
/// Guarded pointer
typedef cds::gc::guarded_ptr< gc, node_type, value_type, details::guarded_ptr_cast_map<node_type, value_type> > guarded_ptr;
- private:
- //@cond
-# ifndef CDS_CXX11_LAMBDA_SUPPORT
- template <typename Func>
- class insert_functor: protected cds::details::functor_wrapper<Func>
- {
- typedef cds::details::functor_wrapper<Func> base_class;
- public:
- insert_functor ( Func f )
- : base_class( f )
- {}
-
- void operator()( node_type& node )
- {
- base_class::get()( node.m_Data );
- }
- };
-
- template <typename Func>
- class ensure_functor: protected cds::details::functor_wrapper<Func>
- {
- typedef cds::details::functor_wrapper<Func> base_class;
- public:
- ensure_functor( Func f )
- : base_class(f)
- {}
-
- void operator ()( bool bNew, node_type& node, node_type& )
- {
- base_class::get()( bNew, node.m_Data );
- }
- };
-
- template <typename Func>
- class find_functor: protected cds::details::functor_wrapper<Func>
- {
- typedef cds::details::functor_wrapper<Func> base_class;
- public:
- find_functor( Func f )
- : base_class(f)
- {}
-
- template <typename Q>
- void operator ()( node_type& node, Q& )
- {
- base_class::get()( node.m_Data );
- }
- };
-
- template <typename Func>
- struct erase_functor
- {
- Func m_func;
-
- erase_functor( Func f )
- : m_func( f )
- {}
-
- void operator ()( node_type const & node )
- {
- cds::unref(m_func)( const_cast<value_type&>(node.m_Data) );
- }
- };
-# endif // ifndef CDS_CXX11_LAMBDA_SUPPORT
- //@endcond
-
protected:
//@cond
template <typename K>
{
scoped_node_ptr pNode( alloc_node( key ));
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
- if ( base_class::insert_at( refHead, *pNode, [&f](node_type& node){ cds::unref(f)( node.m_Data ); }))
-# else
- insert_functor<Func> wrapper( f );
- if ( base_class::insert_at( refHead, *pNode, cds::ref(wrapper) ))
-# endif
- {
+ if ( base_class::insert_at( refHead, *pNode, [&f](node_type& node){ cds::unref(f)( node.m_Data ); })) {
pNode.release();
return true;
}
{
scoped_node_ptr pNode( alloc_node( key ));
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
std::pair<bool, bool> ret = base_class::ensure_at( refHead, *pNode,
[&f]( bool bNew, node_type& node, node_type& ){ cds::unref(f)( bNew, node.m_Data ); });
-# else
- ensure_functor<Func> wrapper( f );
- std::pair<bool, bool> ret = base_class::ensure_at( refHead, *pNode, cds::ref(wrapper));
-# endif
if ( ret.first && ret.second )
pNode.release();
template <typename K, typename Compare, typename Func>
bool erase_at( head_type& refHead, K const& key, Compare cmp, Func f )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return base_class::erase_at( refHead, key, cmp, [&f]( node_type const & node ){ cds::unref(f)( const_cast<value_type&>(node.m_Data)); });
-# else
- erase_functor<Func> wrapper( f );
- return base_class::erase_at( refHead, key, cmp, cds::ref(wrapper) );
-# endif
}
template <typename K, typename Compare>
bool extract_at( head_type& refHead, typename gc::Guard& dest, K const& key, Compare cmp )
template <typename K, typename Compare, typename Func>
bool find_at( head_type& refHead, K& key, Compare cmp, Func f )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return base_class::find_at( refHead, key, cmp, [&f](node_type& node, K const&){ cds::unref(f)( node.m_Data ); });
-# else
- find_functor<Func> wrapper( f );
- return base_class::find_at( refHead, key, cmp, cds::ref(wrapper) );
-# endif
}
template <typename K, typename Compare>
typedef typename base_class::atomic_node_ptr head_type;
//@endcond
- private:
- //@cond
-# ifndef CDS_CXX11_LAMBDA_SUPPORT
- struct ensure_functor
- {
- node_type * m_pItemFound;
-
- ensure_functor()
- : m_pItemFound( nullptr )
- {}
-
- void operator ()(bool, node_type& item, node_type& )
- {
- m_pItemFound = &item;
- }
- };
-
- template <typename Func>
- class find_functor: protected cds::details::functor_wrapper<Func>
- {
- typedef cds::details::functor_wrapper<Func> base_class;
- public:
- find_functor( Func f )
- : base_class(f)
- {}
-
- template <typename Q>
- void operator ()( node_type& node, Q& )
- {
- base_class::get()( node.m_Data );
- }
- };
-# endif
- //@endcond
-
protected:
//@cond
template <typename K>
scoped_node_ptr pNode( alloc_node( key ));
node_type * pItemFound = nullptr;
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
std::pair<bool, bool> ret = base_class::ensure_at( refHead, *pNode, [&pItemFound](bool, node_type& item, node_type&){ pItemFound = &item; });
-# else
- ensure_functor func;
- std::pair<bool, bool> ret = base_class::ensure_at( refHead, *pNode, boost::ref(func) );
- pItemFound = func.m_pItemFound;
-# endif
assert( pItemFound != nullptr );
if ( ret.first && ret.second )
template <typename K, typename Compare typename Func>
bool find_at( head_type& refHead, K& key, Compare cmp, Func f )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return base_class::find_at( refHead, key, cmp, [&f]( node_type& node, K const& ){ cds::unref(f)( node.m_Data ); });
-# else
- find_functor<Func> wrapper( f );
- return base_class::find_at( refHead, key, cmp, cds::ref(wrapper) );
-# endif
}
*/
//@endcond
cds::urcu::details::conventional_exempt_pair_cast<node_type, value_type>
> exempt_ptr;
- private:
- //@cond
-# ifndef CDS_CXX11_LAMBDA_SUPPORT
- template <typename Func>
- class insert_functor: protected cds::details::functor_wrapper<Func>
- {
- typedef cds::details::functor_wrapper<Func> base_class;
- public:
- insert_functor ( Func f )
- : base_class( f )
- {}
-
- void operator()( node_type& node )
- {
- base_class::get()( node.m_Data );
- }
- };
-
- template <typename Func>
- class ensure_functor: protected cds::details::functor_wrapper<Func>
- {
- typedef cds::details::functor_wrapper<Func> base_class;
- public:
- ensure_functor( Func f )
- : base_class(f)
- {}
-
- void operator ()( bool bNew, node_type& node, node_type& )
- {
- base_class::get()( bNew, node.m_Data );
- }
- };
-
- template <typename Func>
- class find_functor: protected cds::details::functor_wrapper<Func>
- {
- typedef cds::details::functor_wrapper<Func> base_class;
- public:
- find_functor( Func f )
- : base_class(f)
- {}
-
- template <typename Q>
- void operator ()( node_type& node, Q& )
- {
- base_class::get()( node.m_Data );
- }
- };
-
- struct empty_find_functor
- {
- template <typename Q>
- void operator ()( node_type& node, Q& val ) const
- {}
- };
-
- template <typename Func>
- struct erase_functor
- {
- Func m_func;
-
- erase_functor( Func f )
- : m_func( f )
- {}
-
- void operator ()( node_type const & node )
- {
- cds::unref(m_func)( const_cast<value_type&>(node.m_Data) );
- }
- };
-# endif // ifndef CDS_CXX11_LAMBDA_SUPPORT
- //@endcond
-
protected:
//@cond
template <typename K>
{
scoped_node_ptr pNode( alloc_node( key ));
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
- if ( base_class::insert_at( refHead, *pNode, [&f](node_type& node){ cds::unref(f)( node.m_Data ); }))
-# else
- insert_functor<Func> wrapper( f );
- if ( base_class::insert_at( refHead, *pNode, cds::ref(wrapper) ))
-# endif
- {
+ if ( base_class::insert_at( refHead, *pNode, [&f](node_type& node){ cds::unref(f)( node.m_Data ); })) {
pNode.release();
return true;
}
{
scoped_node_ptr pNode( alloc_node( key ));
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
std::pair<bool, bool> ret = base_class::ensure_at( refHead, *pNode,
[&f]( bool bNew, node_type& node, node_type& ){ cds::unref(f)( bNew, node.m_Data ); });
-# else
- ensure_functor<Func> wrapper( f );
- std::pair<bool, bool> ret = base_class::ensure_at( refHead, *pNode, cds::ref(wrapper));
-# endif
if ( ret.first && ret.second )
pNode.release();
template <typename K, typename Compare, typename Func>
bool erase_at( head_type& refHead, K const& key, Compare cmp, Func f )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return base_class::erase_at( refHead, key, cmp, [&f]( node_type const & node ){ cds::unref(f)( const_cast<value_type&>(node.m_Data)); });
-# else
- erase_functor<Func> wrapper( f );
- return base_class::erase_at( refHead, key, cmp, cds::ref(wrapper) );
-# endif
}
template <typename K, typename Compare>
template <typename K, typename Compare>
bool find_at( head_type& refHead, K const& key, Compare cmp ) const
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return base_class::find_at( refHead, key, cmp, [](node_type&, K const&) {} );
-# else
- return base_class::find_at( refHead, key, cmp, empty_find_functor() );
-# endif
}
template <typename K, typename Compare, typename Func>
bool find_at( head_type& refHead, K& key, Compare cmp, Func f ) const
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return base_class::find_at( refHead, key, cmp, [&f](node_type& node, K const&){ cds::unref(f)( node.m_Data ); });
-# else
- find_functor<Func> wrapper( f );
- return base_class::find_at( refHead, key, cmp, cds::ref(wrapper) );
-# endif
}
template <typename K, typename Compare>
typedef typename options::type_traits::compare intrusive_key_comparator;
typedef typename base_class::atomic_node_ptr head_type;
-# ifndef CDS_CXX11_LAMBDA_SUPPORT
- typedef typename base_class::empty_erase_functor empty_erase_functor;
-# endif
//@endcond
public:
{
return n.m_Value;
}
-
-# ifndef CDS_CXX11_LAMBDA_SUPPORT
- template <typename Func>
- struct insert_functor
- {
- Func m_func;
-
- insert_functor ( Func f )
- : m_func(f)
- {}
-
- void operator()( node_type& node )
- {
- cds::unref(m_func)( node_to_value(node) );
- }
- };
-
- template <typename Q, typename Func>
- struct ensure_functor
- {
- Func m_func;
- Q const& m_arg;
-
- ensure_functor( Q const& arg, Func f )
- : m_func(f)
- , m_arg( arg )
- {}
-
- void operator ()( bool bNew, node_type& node, node_type& )
- {
- cds::unref(m_func)( bNew, node_to_value(node), m_arg );
- }
- };
-
- template <typename Func>
- struct find_functor
- {
- Func m_func;
-
- find_functor( Func f )
- : m_func(f)
- {}
-
- template <typename Q>
- void operator ()( node_type& node, Q& val )
- {
- cds::unref(m_func)( node_to_value(node), val );
- }
- };
-
- template <typename Func>
- struct erase_functor
- {
- Func m_func;
-
- erase_functor( Func f )
- : m_func(f)
- {}
-
- void operator()( node_type const& node )
- {
- cds::unref(m_func)( node_to_value(node) );
- }
- };
-#endif // ifndef CDS_CXX11_LAMBDA_SUPPORT
//@endcond
protected:
template <typename Q>
bool erase( Q const& key )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return erase_at( head(), key, intrusive_key_comparator(), [](value_type const&){} );
-# else
- return erase_at( head(), key, intrusive_key_comparator(), empty_erase_functor() );
-# endif
}
/// Deletes the item from the list using \p pred predicate for searching
template <typename Q, typename Less>
bool erase_with( Q const& key, Less pred )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return erase_at( head(), key, typename options::template less_wrapper<Less>::type(), [](value_type const&){} );
-# else
- return erase_at( head(), key, typename options::template less_wrapper<Less>::type(), empty_erase_functor() );
-# endif
}
/// Deletes \p key from the list
{
scoped_node_ptr pNode( alloc_node( key ));
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
-# ifdef CDS_BUG_STATIC_MEMBER_IN_LAMBDA
- // GCC 4.5,4.6,4.7: node_to_value is unaccessible from lambda,
- // like as MichaelList::node_to_value that requires to capture *this* despite on node_to_value is static function
- value_type& (* n2v)( node_type& ) = node_to_value;
- if ( base_class::insert_at( refHead, *pNode, [&f, n2v]( node_type& node ) { cds::unref(f)( n2v(node) ); } ))
-# else
- if ( base_class::insert_at( refHead, *pNode, [&f]( node_type& node ) { cds::unref(f)( node_to_value(node) ); } ))
-# endif
-# else
- insert_functor<Func> wrapper( f );
- if ( base_class::insert_at( refHead, *pNode, cds::ref(wrapper) ))
-# endif
- {
+ if ( base_class::insert_at( refHead, *pNode, [&f]( node_type& node ) { cds::unref(f)( node_to_value(node) ); } )) {
pNode.release();
return true;
}
template <typename Q, typename Compare, typename Func>
bool erase_at( head_type& refHead, Q const& key, Compare cmp, Func f )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
-# ifdef CDS_BUG_STATIC_MEMBER_IN_LAMBDA
- // GCC 4.5-4.7: node_to_value is unaccessible from lambda,
- // like as MichaelList::node_to_value that requires to capture *this* despite on node_to_value is static function
- value_type const& (* n2v)( node_type const& ) = node_to_value;
- return base_class::erase_at( refHead, key, cmp, [&f,n2v](node_type const& node){ cds::unref(f)( n2v(node) ); } );
-# else
return base_class::erase_at( refHead, key, cmp, [&f](node_type const& node){ cds::unref(f)( node_to_value(node) ); } );
-# endif
-# else
- erase_functor<Func> wrapper( f );
- return base_class::erase_at( refHead, key, cmp, cds::ref(wrapper) );
-# endif
}
template <typename Q, typename Compare>
{
scoped_node_ptr pNode( alloc_node( key ));
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
-# ifdef CDS_BUG_STATIC_MEMBER_IN_LAMBDA
- // GCC 4.5-4.7: node_to_value is unaccessible from lambda,
- // like as MichaelList::node_to_value that requires to capture *this* despite on node_to_value is static function
- value_type& (* n2v)( node_type& ) = node_to_value;
- std::pair<bool, bool> ret = base_class::ensure_at( refHead, *pNode,
- [&f, &key, n2v](bool bNew, node_type& node, node_type&){ cds::unref(f)( bNew, n2v(node), key ); });
-# else
std::pair<bool, bool> ret = base_class::ensure_at( refHead, *pNode,
[&f, &key](bool bNew, node_type& node, node_type&){ cds::unref(f)( bNew, node_to_value(node), key ); });
-# endif
-# else
- ensure_functor<Q, Func> wrapper( key, f );
- std::pair<bool, bool> ret = base_class::ensure_at( refHead, *pNode, cds::ref(wrapper));
-# endif
if ( ret.first && ret.second )
pNode.release();
template <typename Q, typename Compare, typename Func>
bool find_at( head_type& refHead, Q& val, Compare cmp, Func f )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
-# ifdef CDS_BUG_STATIC_MEMBER_IN_LAMBDA
- // GCC 4.5-4.7: node_to_value is unaccessible from lambda,
- // like as MichaelList::node_to_value that requires to capture *this* despite on node_to_value is static function
- value_type& (* n2v)( node_type& ) = node_to_value;
- return base_class::find_at( refHead, val, cmp, [&f, n2v](node_type& node, Q& v){ cds::unref(f)( n2v(node), v ); });
-# else
return base_class::find_at( refHead, val, cmp, [&f](node_type& node, Q& v){ cds::unref(f)( node_to_value(node), v ); });
-# endif
-# else
- find_functor<Func> wrapper( f );
- return base_class::find_at( refHead, val, cmp, cds::ref(wrapper) );
-# endif
}
template <typename Q, typename Compare>
typedef typename base_class::atomic_node_ptr head_type;
//@endcond
- protected:
- //@cond
-# ifndef CDS_CXX11_LAMBDA_SUPPORT
- struct ensure_functor
- {
- node_type * m_pItemFound;
-
- ensure_functor()
- : m_pItemFound( nullptr )
- {}
-
- void operator ()(bool, node_type& item, node_type& )
- {
- m_pItemFound = &item;
- }
- };
-# endif
- //@endcond
-
protected:
//@cond
static node_type * alloc_node()
scoped_node_ptr pNode( alloc_node( val ));
node_type * pItemFound = nullptr;
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
std::pair<bool, bool> ret = base_class::ensure_at( refHead, *pNode, [&pItemFound](bool, node_type& item, node_type&) { pItemFound = &item; });
-# else
- ensure_functor func;
- std::pair<bool, bool> ret = base_class::ensure_at( refHead, *pNode, boost::ref(func) );
- pItemFound = func.m_pItemFound;
-# endif
assert( pItemFound != nullptr );
if ( ret.first && ret.second )
typedef typename options::type_traits::compare intrusive_key_comparator;
typedef typename base_class::atomic_node_ptr head_type;
-# ifndef CDS_CXX11_LAMBDA_SUPPORT
- typedef typename base_class::empty_erase_functor empty_erase_functor;
-# endif
//@endcond
public:
{
return n.m_Value;
}
-
-# ifndef CDS_CXX11_LAMBDA_SUPPORT
- template <typename Func>
- struct insert_functor
- {
- Func m_func;
-
- insert_functor ( Func f )
- : m_func(f)
- {}
-
- void operator()( node_type& node )
- {
- cds::unref(m_func)( node_to_value(node) );
- }
- };
-
- template <typename Q, typename Func>
- struct ensure_functor
- {
- Func m_func;
- Q const& m_arg;
-
- ensure_functor( Q const& arg, Func f )
- : m_func(f)
- , m_arg( arg )
- {}
-
- void operator ()( bool bNew, node_type& node, node_type& )
- {
- cds::unref(m_func)( bNew, node_to_value(node), m_arg );
- }
- };
-
- template <typename Func>
- struct find_functor
- {
- Func m_func;
-
- find_functor( Func f )
- : m_func(f)
- {}
-
- template <typename Q>
- void operator ()( node_type& node, Q& val )
- {
- cds::unref(m_func)( node_to_value(node), val );
- }
- };
-
- struct empty_find_functor
- {
- template <typename Q>
- void operator ()( node_type& node, Q& val ) const
- {}
- };
-
- template <typename Func>
- struct erase_functor
- {
- Func m_func;
-
- erase_functor( Func f )
- : m_func(f)
- {}
-
- void operator()( node_type const& node )
- {
- cds::unref(m_func)( node_to_value(node) );
- }
- };
-#endif // ifndef CDS_CXX11_LAMBDA_SUPPORT
//@endcond
protected:
template <typename Q>
bool erase( Q const& key )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return erase_at( head(), key, intrusive_key_comparator(), [](value_type const&){} );
-# else
- return erase_at( head(), key, intrusive_key_comparator(), empty_erase_functor() );
-# endif
}
/// Deletes the item from the list using \p pred predicate for searching
template <typename Q, typename Less>
bool erase_with( Q const& key, Less pred )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return erase_at( head(), key, typename options::template less_wrapper<Less>::type(), [](value_type const&){} );
-# else
- return erase_at( head(), key, typename options::template less_wrapper<Less>::type(), empty_erase_functor() );
-# endif
}
/// Deletes \p key from the list
{
scoped_node_ptr pNode( alloc_node( key ));
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
-# ifdef CDS_BUG_STATIC_MEMBER_IN_LAMBDA
- // GCC 4.5,4.6,4.7: node_to_value is unaccessible from lambda,
- // like as MichaelList::node_to_value that requires to capture *this* despite on node_to_value is static function
- value_type& (* n2v)( node_type& ) = node_to_value;
- if ( base_class::insert_at( refHead, *pNode, [&f, n2v]( node_type& node ) { cds::unref(f)( n2v(node) ); } ))
-# else
- if ( base_class::insert_at( refHead, *pNode, [&f]( node_type& node ) { cds::unref(f)( node_to_value(node) ); } ))
-# endif
-# else
- insert_functor<Func> wrapper( f );
- if ( base_class::insert_at( refHead, *pNode, cds::ref(wrapper) ))
-# endif
- {
+ if ( base_class::insert_at( refHead, *pNode, [&f]( node_type& node ) { cds::unref(f)( node_to_value(node) ); } )) {
pNode.release();
return true;
}
template <typename Q, typename Compare, typename Func>
bool erase_at( head_type& refHead, Q const& key, Compare cmp, Func f )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
-# ifdef CDS_BUG_STATIC_MEMBER_IN_LAMBDA
- // GCC 4.5-4.7: node_to_value is unaccessible from lambda,
- // like as MichaelList::node_to_value that requires to capture *this* despite on node_to_value is static function
- value_type const& (* n2v)( node_type const& ) = node_to_value;
- return base_class::erase_at( refHead, key, cmp, [&f,n2v](node_type const& node){ cds::unref(f)( n2v(node) ); } );
-# else
return base_class::erase_at( refHead, key, cmp, [&f](node_type const& node){ cds::unref(f)( node_to_value(node) ); } );
-# endif
-# else
- erase_functor<Func> wrapper( f );
- return base_class::erase_at( refHead, key, cmp, cds::ref(wrapper) );
-# endif
}
template <typename Q, typename Func>
{
scoped_node_ptr pNode( alloc_node( key ));
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
-# ifdef CDS_BUG_STATIC_MEMBER_IN_LAMBDA
- // GCC 4.5-4.7: node_to_value is unaccessible from lambda,
- // like as MichaelList::node_to_value that requires to capture *this* despite on node_to_value is static function
- value_type& (* n2v)( node_type& ) = node_to_value;
- std::pair<bool, bool> ret = base_class::ensure_at( refHead, *pNode,
- [&f, &key, n2v](bool bNew, node_type& node, node_type&){ cds::unref(f)( bNew, n2v(node), key ); });
-# else
std::pair<bool, bool> ret = base_class::ensure_at( refHead, *pNode,
[&f, &key](bool bNew, node_type& node, node_type&){ cds::unref(f)( bNew, node_to_value(node), key ); });
-# endif
-# else
- ensure_functor<Q, Func> wrapper( key, f );
- std::pair<bool, bool> ret = base_class::ensure_at( refHead, *pNode, cds::ref(wrapper));
-# endif
if ( ret.first && ret.second )
pNode.release();
template <typename Q, typename Compare>
bool find_at( head_type& refHead, Q const& key, Compare cmp ) const
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return base_class::find_at( refHead, key, cmp, [](node_type&, Q const &) {} );
-# else
- return base_class::find_at( refHead, key, cmp, empty_find_functor() );
-# endif
}
template <typename Q, typename Compare, typename Func>
bool find_at( head_type& refHead, Q& val, Compare cmp, Func f ) const
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
-# ifdef CDS_BUG_STATIC_MEMBER_IN_LAMBDA
- // GCC 4.5-4.7: node_to_value is unaccessible from lambda,
- // like as MichaelList::node_to_value that requires to capture *this* despite on node_to_value is static function
- value_type& (* n2v)( node_type& ) = node_to_value;
- return base_class::find_at( refHead, val, cmp, [&f, n2v](node_type& node, Q& v){ cds::unref(f)( n2v(node), v ); });
-# else
return base_class::find_at( refHead, val, cmp, [&f](node_type& node, Q& v){ cds::unref(f)( node_to_value(node), v ); });
-# endif
-# else
- find_functor<Func> wrapper( f );
- return base_class::find_at( refHead, val, cmp, cds::ref(wrapper) );
-# endif
}
template <typename Q, typename Compare>
{
cxx_allocator().Delete( p );
}
-# ifndef CDS_CXX11_LAMBDA_SUPPORT
- void operator()( value_type& p ) const
- {
- cxx_allocator().Delete( &p );
- }
-# endif
};
typedef std::unique_ptr<value_type, value_deleter> scoped_ptr;
-
-# ifndef CDS_CXX11_LAMBDA_SUPPORT
- template <typename Func>
- struct clear_wrapper
- {
- Func& func;
- clear_wrapper( Func& f ): func(f) {}
-
- void operator()( value_type& src ) const
- {
- cds::unref(func)( src );
- value_deleter()( &src );
- }
- };
-# endif
-
//@endcond
public:
*/
void clear()
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
base_class::clear_with( []( value_type& src ) { cxx_allocator().Delete( &src ); });
-# else
- base_class::clear_with( value_deleter() );
-# endif
}
/// Clears the queue (not atomic)
template <typename Func>
void clear_with( Func f )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
base_class::clear_with( [&f]( value_type& val ) { cds::unref(f)(val); value_deleter()( &val ); } );
-# else
- clear_wrapper<Func> c(f);
- base_class::clear_with( cds::ref(c));
-# endif
}
/// Checks is the priority queue is empty
}
//@endcond
- protected:
- //@cond
-# ifndef CDS_CXX11_LAMBDA_SUPPORT
- struct empty_insert_functor
- {
- void operator()( value_type& ) const
- {}
- };
-
- template <typename Q>
- class insert_value_functor
- {
- Q const& m_val;
- public:
- insert_value_functor( Q const & v)
- : m_val(v)
- {}
-
- void operator()( value_type& item )
- {
- item.second = m_val;
- }
- };
-
- template <typename Func>
- class insert_key_wrapper: protected cds::details::functor_wrapper<Func>
- {
- typedef cds::details::functor_wrapper<Func> base_class;
- public:
- insert_key_wrapper( Func f ): base_class(f) {}
-
- void operator()( node_type& item )
- {
- base_class::get()( item.m_Value );
- }
- };
-
- template <typename Func>
- class ensure_wrapper: protected cds::details::functor_wrapper<Func>
- {
- typedef cds::details::functor_wrapper<Func> base_class;
- public:
- ensure_wrapper( Func f) : base_class(f) {}
-
- void operator()( bool bNew, node_type& item, node_type const& )
- {
- base_class::get()( bNew, item.m_Value );
- }
- };
-
- template <typename Func>
- struct erase_functor
- {
- Func m_func;
-
- erase_functor( Func f )
- : m_func(f)
- {}
-
- void operator()( node_type& node )
- {
- cds::unref(m_func)( node.m_Value );
- }
- };
-
- template <typename Func>
- class find_wrapper: protected cds::details::functor_wrapper<Func>
- {
- typedef cds::details::functor_wrapper<Func> base_class;
- public:
- find_wrapper( Func f )
- : base_class(f)
- {}
-
- template <typename Q>
- void operator()( node_type& item, Q& val )
- {
- base_class::get()( item.m_Value, val );
- }
- };
-# endif // #ifndef CDS_CXX11_LAMBDA_SUPPORT
- //@endcond
-
public:
/// Default ctor
SkipListMap()
template <typename K>
bool insert( K const& key )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return insert_key( key, [](value_type&){} );
-# else
- return insert_key( key, empty_insert_functor() );
-# endif
}
/// Inserts new node
template <typename K, typename V>
bool insert( K const& key, V const& val )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return insert_key( key, [&val](value_type& item) { item.second = val ; } );
-# else
- insert_value_functor<V> f(val);
- return insert_key( key, cds::ref(f) );
-# endif
}
/// Inserts new node and initialize it by a functor
bool insert_key( const K& key, Func func )
{
scoped_node_ptr pNode( node_allocator().New( random_level(), key ));
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
- if ( base_class::insert( *pNode, [&func]( node_type& item ) { cds::unref(func)( item.m_Value ); } ))
-# else
- insert_key_wrapper<Func> wrapper(func);
- if ( base_class::insert( *pNode, cds::ref(wrapper) ))
-#endif
- {
+ if ( base_class::insert( *pNode, [&func]( node_type& item ) { cds::unref(func)( item.m_Value ); } )) {
pNode.release();
return true;
}
std::pair<bool, bool> ensure( K const& key, Func func )
{
scoped_node_ptr pNode( node_allocator().New( random_level(), key ));
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
std::pair<bool, bool> res = base_class::ensure( *pNode,
[&func](bool bNew, node_type& item, node_type const& ){ cds::unref(func)( bNew, item.m_Value ); }
);
-# else
- ensure_wrapper<Func> wrapper( func );
- std::pair<bool, bool> res = base_class::ensure( *pNode, cds::ref(wrapper) );
-# endif
if ( res.first && res.second )
pNode.release();
return res;
template <typename K, typename Func>
bool erase( K const& key, Func f )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return base_class::erase( key, [&f]( node_type& node) { cds::unref(f)( node.m_Value ); } );
-# else
- erase_functor<Func> wrapper(f);
- return base_class::erase( key, cds::ref(wrapper));
-# endif
}
/// Deletes the item from the map using \p pred predicate for searching
template <typename K, typename Less, typename Func>
bool erase_with( K const& key, Less pred, Func f )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return base_class::erase_with( key,
cds::details::predicate_wrapper< node_type, Less, typename maker::key_accessor >(),
[&f]( node_type& node) { cds::unref(f)( node.m_Value ); } );
-# else
- erase_functor<Func> wrapper(f);
- return base_class::erase_with( key, cds::details::predicate_wrapper< node_type, Less, typename maker::key_accessor >(), cds::ref(wrapper));
-# endif
}
/// Extracts the item from the map with specified \p key
template <typename K, typename Func>
bool find( K const& key, Func f )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return base_class::find( key, [&f](node_type& item, K const& ) { cds::unref(f)( item.m_Value );});
-# else
- find_wrapper<Func> wrapper(f);
- return base_class::find( key, cds::ref(wrapper) );
-# endif
}
/// Finds the key \p val using \p pred predicate for searching
template <typename K, typename Less, typename Func>
bool find_with( K const& key, Less pred, Func f )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return base_class::find_with( key,
cds::details::predicate_wrapper< node_type, Less, typename maker::key_accessor >(),
[&f](node_type& item, K const& ) { cds::unref(f)( item.m_Value );});
-# else
- find_wrapper<Func> wrapper(f);
- return base_class::find_with( key, cds::details::predicate_wrapper< node_type, Less, typename maker::key_accessor >(), cds::ref(wrapper) );
-# endif
}
/// Find the key \p key
}
//@endcond
- protected:
- //@cond
-# ifndef CDS_CXX11_LAMBDA_SUPPORT
- struct empty_insert_functor
- {
- void operator()( value_type& ) const
- {}
- };
-
- template <typename Q>
- class insert_value_functor
- {
- Q const& m_val;
- public:
- insert_value_functor( Q const& v)
- : m_val(v)
- {}
-
- void operator()( value_type& item )
- {
- item.second = m_val;
- }
- };
-
- template <typename Func>
- class insert_key_wrapper: protected cds::details::functor_wrapper<Func>
- {
- typedef cds::details::functor_wrapper<Func> base_class;
- public:
- insert_key_wrapper( Func f ): base_class(f) {}
-
- void operator()( node_type& item )
- {
- base_class::get()( item.m_Value );
- }
- };
-
- template <typename Func>
- class ensure_wrapper: protected cds::details::functor_wrapper<Func>
- {
- typedef cds::details::functor_wrapper<Func> base_class;
- public:
- ensure_wrapper( Func f) : base_class(f) {}
-
- void operator()( bool bNew, node_type& item, node_type const& )
- {
- base_class::get()( bNew, item.m_Value );
- }
- };
-
- template <typename Func>
- struct erase_functor
- {
- Func m_func;
-
- erase_functor( Func f )
- : m_func(f)
- {}
-
- void operator()( node_type& node )
- {
- cds::unref(m_func)( node.m_Value );
- }
- };
-
- template <typename Func>
- class find_wrapper: protected cds::details::functor_wrapper<Func>
- {
- typedef cds::details::functor_wrapper<Func> base_class;
- public:
- find_wrapper( Func f )
- : base_class(f)
- {}
-
- template <typename Q>
- void operator()( node_type& item, Q& val )
- {
- base_class::get()( item.m_Value, val );
- }
- };
-
- template <typename Func>
- struct extract_copy_wrapper
- {
- Func m_func;
- extract_copy_wrapper( Func f )
- : m_func(f)
- {}
-
- template <typename Q>
- void operator()( Q& dest, node_type& src )
- {
- cds::unref(m_func)(dest, src.m_Value);
- }
- };
-
-# endif // #ifndef CDS_CXX11_LAMBDA_SUPPORT
- //@endcond
-
public:
/// Default ctor
SkipListMap()
template <typename K>
bool insert( K const& key )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return insert_key( key, [](value_type&){} );
-# else
- return insert_key( key, empty_insert_functor() );
-# endif
}
/// Inserts new node
template <typename K, typename V>
bool insert( K const& key, V const& val )
{
- /*
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
- return insert_key( key, [&val](value_type& item) { item.second = val ; } );
-# else
- insert_value_functor<V> f(val);
- return insert_key( key, cds::ref(f) );
-# endif
- */
scoped_node_ptr pNode( node_allocator().New( random_level(), key, val ));
if ( base_class::insert( *pNode ))
{
bool insert_key( const K& key, Func func )
{
scoped_node_ptr pNode( node_allocator().New( random_level(), key ));
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
- if ( base_class::insert( *pNode, [&func]( node_type& item ) { cds::unref(func)( item.m_Value ); } ))
-# else
- insert_key_wrapper<Func> wrapper(func);
- if ( base_class::insert( *pNode, cds::ref(wrapper) ))
-#endif
- {
+ if ( base_class::insert( *pNode, [&func]( node_type& item ) { cds::unref(func)( item.m_Value ); } )) {
pNode.release();
return true;
}
std::pair<bool, bool> ensure( K const& key, Func func )
{
scoped_node_ptr pNode( node_allocator().New( random_level(), key ));
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
std::pair<bool, bool> res = base_class::ensure( *pNode,
[&func](bool bNew, node_type& item, node_type const& ){ cds::unref(func)( bNew, item.m_Value ); }
);
-# else
- ensure_wrapper<Func> wrapper( func );
- std::pair<bool, bool> res = base_class::ensure( *pNode, cds::ref(wrapper) );
-# endif
if ( res.first && res.second )
pNode.release();
return res;
template <typename K, typename Func>
bool erase( K const& key, Func f )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return base_class::erase( key, [&f]( node_type& node) { cds::unref(f)( node.m_Value ); } );
-# else
- erase_functor<Func> wrapper(f);
- return base_class::erase( key, cds::ref(wrapper));
-# endif
}
/// Deletes the item from the map using \p pred predicate for searching
template <typename K, typename Less, typename Func>
bool erase_with( K const& key, Less pred, Func f )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return base_class::erase_with( key, cds::details::predicate_wrapper< node_type, Less, typename maker::key_accessor >(),
[&f]( node_type& node) { cds::unref(f)( node.m_Value ); } );
-# else
- erase_functor<Func> wrapper(f);
- return base_class::erase_with( key, cds::details::predicate_wrapper< node_type, Less, typename maker::key_accessor >(), cds::ref(wrapper));
-# endif
}
/// Extracts the item from the map with specified \p key
template <typename K, typename Func>
bool find( K const& key, Func f )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return base_class::find( key, [&f](node_type& item, K const& ) { cds::unref(f)( item.m_Value );});
-# else
- find_wrapper<Func> wrapper(f);
- return base_class::find( key, cds::ref(wrapper) );
-# endif
}
/// Finds the key \p val using \p pred predicate for searching
template <typename K, typename Less, typename Func>
bool find_with( K const& key, Less pred, Func f )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return base_class::find_with( key, cds::details::predicate_wrapper< node_type, Less, typename maker::key_accessor >(),
[&f](node_type& item, K const& ) { cds::unref(f)( item.m_Value );});
-# else
- find_wrapper<Func> wrapper(f);
- return base_class::find_with( key, cds::details::predicate_wrapper< node_type, Less, typename maker::key_accessor >(), cds::ref(wrapper) );
-# endif
}
/// Find the key \p key
}
//@endcond
- protected:
- //@cond
-# ifndef CDS_CXX11_LAMBDA_SUPPORT
- template <typename Func>
- struct insert_functor
- {
- Func m_func;
-
- insert_functor ( Func f )
- : m_func(f)
- {}
-
- void operator()( node_type& node )
- {
- cds::unref(m_func)( node.m_Value );
- }
- };
-
- template <typename Q, typename Func>
- struct ensure_functor
- {
- Func m_func;
- Q const& m_arg;
-
- ensure_functor( Q const& arg, Func f )
- : m_func(f)
- , m_arg( arg )
- {}
-
- void operator ()( bool bNew, node_type& node, node_type& )
- {
- cds::unref(m_func)( bNew, node.m_Value, m_arg );
- }
- };
-
- template <typename Func>
- struct find_functor
- {
- Func m_func;
-
- find_functor( Func f )
- : m_func(f)
- {}
-
- template <typename Q>
- void operator ()( node_type& node, Q& val )
- {
- cds::unref(m_func)( node.m_Value, val );
- }
- };
-
- struct copy_value_functor {
- template <typename Q>
- void operator()( Q& dest, value_type const& src ) const
- {
- dest = src;
- }
- };
-
- template <typename Func>
- struct erase_functor
- {
- Func m_func;
-
- erase_functor( Func f )
- : m_func(f)
- {}
-
- void operator()( node_type const& node )
- {
- cds::unref(m_func)( node.m_Value );
- }
- };
-# endif // ifndef CDS_CXX11_LAMBDA_SUPPORT
-
- //@endcond
-
public:
/// Default ctor
SkipListSet()
bool insert( Q const& val, Func f )
{
scoped_node_ptr sp( node_allocator().New( random_level(), val ));
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
- if ( base_class::insert( *sp.get(), [&f]( node_type& val ) { cds::unref(f)( val.m_Value ); } ))
-# else
- insert_functor<Func> wrapper(f);
- if ( base_class::insert( *sp, cds::ref(wrapper) ))
-# endif
- {
+ if ( base_class::insert( *sp.get(), [&f]( node_type& val ) { cds::unref(f)( val.m_Value ); } )) {
sp.release();
return true;
}
std::pair<bool, bool> ensure( const Q& val, Func func )
{
scoped_node_ptr sp( node_allocator().New( random_level(), val ));
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
std::pair<bool, bool> bRes = base_class::ensure( *sp,
[&func, &val](bool bNew, node_type& node, node_type&){ cds::unref(func)( bNew, node.m_Value, val ); });
-# else
- ensure_functor<Q, Func> wrapper( val, func );
- std::pair<bool, bool> bRes = base_class::ensure( *sp, cds::ref(wrapper));
-# endif
if ( bRes.first && bRes.second )
sp.release();
return bRes;
template <typename Q, typename Func>
bool erase( Q const& key, Func f )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return base_class::erase( key, [&f]( node_type const& node) { cds::unref(f)( node.m_Value ); } );
-# else
- erase_functor<Func> wrapper(f);
- return base_class::erase( key, cds::ref(wrapper));
-# endif
}
/// Deletes the item from the set using \p pred predicate for searching
template <typename Q, typename Less, typename Func>
bool erase_with( Q const& key, Less pred, Func f )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return base_class::erase_with( key, cds::details::predicate_wrapper< node_type, Less, typename maker::value_accessor >(),
[&f]( node_type const& node) { cds::unref(f)( node.m_Value ); } );
-# else
- erase_functor<Func> wrapper(f);
- return base_class::erase_with( key, cds::details::predicate_wrapper< node_type, Less, typename maker::value_accessor >(),
- cds::ref(wrapper));
-# endif
}
/// Extracts the item from the set with specified \p key
template <typename Q, typename Func>
bool find( Q& val, Func f )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return base_class::find( val, [&f]( node_type& node, Q& v ) { cds::unref(f)( node.m_Value, v ); });
-# else
- find_functor<Func> wrapper(f);
- return base_class::find( val, cds::ref(wrapper));
-# endif
}
/// Finds the key \p val using \p pred predicate for searching
template <typename Q, typename Less, typename Func>
bool find_with( Q& val, Less pred, Func f )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return base_class::find_with( val, cds::details::predicate_wrapper< node_type, Less, typename maker::value_accessor >(),
[&f]( node_type& node, Q& v ) { cds::unref(f)( node.m_Value, v ); } );
-# else
- find_functor<Func> wrapper(f);
- return base_class::find_with( val, cds::details::predicate_wrapper< node_type, Less, typename maker::value_accessor >(), cds::ref(wrapper));
-# endif
}
/// Find the key \p val
template <typename Q, typename Func>
bool find( Q const& val, Func f )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return base_class::find( val, [&f]( node_type& node, Q const& v ) { cds::unref(f)( node.m_Value, v ); });
-# else
- find_functor<Func> wrapper(f);
- return base_class::find( val, cds::ref(wrapper));
-# endif
}
/// Finds the key \p val using \p pred predicate for searching
template <typename Q, typename Less, typename Func>
bool find_with( Q const& val, Less cmp, Func f )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return base_class::find_with( val, cds::details::predicate_wrapper< node_type, Less, typename maker::value_accessor >(),
[&f]( node_type& node, Q const& v ) { cds::unref(f)( node.m_Value, v ); } );
-# else
- find_functor<Func> wrapper(f);
- return base_class::find_with( val, cds::details::predicate_wrapper< node_type, Less, typename maker::value_accessor >(),
- cds::ref(wrapper));
-# endif
}
/// Find the key \p val
>::type key_accessor;
typedef std::unique_ptr< node_type, typename maker::node_deallocator > scoped_node_ptr;
-
-# ifndef CDS_CXX11_LAMBDA_SUPPORT
- struct ensure_functor
- {
- node_type * pNode;
- void operator ()( bool bNew, node_type& node, node_type& )
- {
- pNode = &node;
- }
- };
-
- struct find_functor
- {
- node_type * pNode;
-
- template <typename Q>
- void operator ()( node_type& node, Q& )
- {
- pNode = &node;
- }
- };
-# endif
//@endcond
public:
std::pair<iterator, bool> ensure( const Q& val )
{
scoped_node_ptr sp( node_allocator().New( base_class::random_level(), val ));
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
node_type * pNode;
std::pair<bool, bool> bRes = base_class::ensure( *sp, [&pNode](bool, node_type& item, node_type&) { pNode = &item; } );
if ( bRes.first && bRes.second )
sp.release();
assert( pNode );
return std::make_pair( node_to_iterator( pNode ), bRes.second );
-# else
- ensure_functor f;
- std::pair<bool, bool> bRes = base_class::ensure( *sp, cds::ref(f) );
- if ( bRes.first && bRes.second )
- sp.release();
- assert( f.pNode );
- return std::make_pair( node_to_iterator( f.pNode ), bRes.second );
-# endif
}
/// Searches \p key
}
//@endcond
- protected:
- //@cond
-# ifndef CDS_CXX11_LAMBDA_SUPPORT
- template <typename Func>
- struct insert_functor
- {
- Func m_func;
-
- insert_functor ( Func f )
- : m_func(f)
- {}
-
- void operator()( node_type& node )
- {
- cds::unref(m_func)( node.m_Value );
- }
- };
-
- template <typename Q, typename Func>
- struct ensure_functor
- {
- Func m_func;
- Q const& m_arg;
-
- ensure_functor( Q const& arg, Func f )
- : m_func(f)
- , m_arg( arg )
- {}
-
- void operator ()( bool bNew, node_type& node, node_type& )
- {
- cds::unref(m_func)( bNew, node.m_Value, m_arg );
- }
- };
-
- template <typename Func>
- struct find_functor
- {
- Func m_func;
-
- find_functor( Func f )
- : m_func(f)
- {}
-
- template <typename Q>
- void operator ()( node_type& node, Q& val )
- {
- cds::unref(m_func)( node.m_Value, val );
- }
- };
-
- template <typename Func>
- struct erase_functor
- {
- Func m_func;
-
- erase_functor( Func f )
- : m_func(f)
- {}
-
- void operator()( node_type const& node )
- {
- cds::unref(m_func)( node.m_Value );
- }
- };
-
- template <typename Func>
- struct extract_copy_wrapper
- {
- Func m_func;
- extract_copy_wrapper( Func f )
- : m_func(f)
- {}
-
- template <typename Q>
- void operator()( Q& dest, node_type& src )
- {
- cds::unref(m_func)(dest, src.m_Value);
- }
- };
-
- struct extract_assign_wrapper
- {
- template <typename Q>
- void operator()( Q& dest, node_type& src ) const
- {
- dest = src.m_Value;
- }
- };
-# endif // ifndef CDS_CXX11_LAMBDA_SUPPORT
-
- //@endcond
-
public:
/// Default ctor
SkipListSet()
bool insert( Q const& val, Func f )
{
scoped_node_ptr sp( node_allocator().New( random_level(), val ));
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
- if ( base_class::insert( *sp.get(), [&f]( node_type& val ) { cds::unref(f)( val.m_Value ); } ))
-# else
- insert_functor<Func> wrapper(f);
- if ( base_class::insert( *sp, cds::ref(wrapper) ))
-# endif
- {
+ if ( base_class::insert( *sp.get(), [&f]( node_type& val ) { cds::unref(f)( val.m_Value ); } )) {
sp.release();
return true;
}
std::pair<bool, bool> ensure( const Q& val, Func func )
{
scoped_node_ptr sp( node_allocator().New( random_level(), val ));
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
std::pair<bool, bool> bRes = base_class::ensure( *sp,
[&func, &val](bool bNew, node_type& node, node_type&){ cds::unref(func)( bNew, node.m_Value, val ); });
-# else
- ensure_functor<Q, Func> wrapper( val, func );
- std::pair<bool, bool> bRes = base_class::ensure( *sp, cds::ref(wrapper));
-# endif
if ( bRes.first && bRes.second )
sp.release();
return bRes;
template <typename Q, typename Func>
bool erase( Q const& key, Func f )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return base_class::erase( key, [&f]( node_type const& node) { cds::unref(f)( node.m_Value ); } );
-# else
- erase_functor<Func> wrapper(f);
- return base_class::erase( key, cds::ref(wrapper));
-# endif
}
/// Deletes the item from the set using \p pred predicate for searching
template <typename Q, typename Less, typename Func>
bool erase_with( Q const& key, Less pred, Func f )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return base_class::erase_with( key, cds::details::predicate_wrapper< node_type, Less, typename maker::value_accessor >(),
[&f]( node_type const& node) { cds::unref(f)( node.m_Value ); } );
-# else
- erase_functor<Func> wrapper(f);
- return base_class::erase_with( key, cds::details::predicate_wrapper< node_type, Less, typename maker::value_accessor >(), cds::ref(wrapper));
-# endif
}
/// Extracts the item from the set with specified \p key
template <typename Q, typename Func>
bool find( Q& val, Func f )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return base_class::find( val, [&f]( node_type& node, Q& v ) { cds::unref(f)( node.m_Value, v ); });
-# else
- find_functor<Func> wrapper(f);
- return base_class::find( val, cds::ref(wrapper));
-# endif
}
/// Finds the key \p val using \p pred predicate for searching
template <typename Q, typename Less, typename Func>
bool find_with( Q& val, Less pred, Func f )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return base_class::find_with( val, cds::details::predicate_wrapper< node_type, Less, typename maker::value_accessor >(),
[&f]( node_type& node, Q& v ) { cds::unref(f)( node.m_Value, v ); } );
-# else
- find_functor<Func> wrapper(f);
- return base_class::find_with( val, cds::details::predicate_wrapper< node_type, Less, typename maker::value_accessor >(),
- cds::ref(wrapper));
-# endif
}
/// Find the key \p val
template <typename Q, typename Func>
bool find( Q const& val, Func f )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return base_class::find( val, [&f]( node_type& node, Q const& v ) { cds::unref(f)( node.m_Value, v ); });
-# else
- find_functor<Func> wrapper(f);
- return base_class::find( val, cds::ref(wrapper));
-# endif
}
/// Finds the key \p val using \p pred predicate for searching
template <typename Q, typename Less, typename Func>
bool find_with( Q const& val, Less pred, Func f )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return base_class::find_with( val, cds::details::predicate_wrapper< node_type, Less, typename maker::value_accessor >(),
[&f]( node_type& node, Q const& v ) { cds::unref(f)( node.m_Value, v ); } );
-# else
- find_functor<Func> wrapper(f);
- return base_class::find_with( val, cds::details::predicate_wrapper< node_type, Less, typename maker::value_accessor >(),
- cds::ref(wrapper));
-# endif
}
/// Find the key \p val
//@cond
typedef typename base_class::maker::type_traits::key_accessor key_accessor;
typedef typename base_class::node_type node_type;
+ //@endcond
public:
/// Guarded pointer
typedef cds::gc::guarded_ptr< gc, node_type, value_type, details::guarded_ptr_cast_set<node_type, value_type> > guarded_ptr;
-
-# ifndef CDS_CXX11_LAMBDA_SUPPORT
- template <typename Func>
- class ensure_functor_wrapper: protected cds::details::functor_wrapper<Func>
- {
- typedef cds::details::functor_wrapper<Func> base_class;
- public:
- ensure_functor_wrapper() {}
- ensure_functor_wrapper( Func f ): base_class(f) {}
-
- template <typename Q>
- void operator()( bool bNew, value_type& item, const Q& /*val*/ )
- {
- base_class::get()( bNew, item );
- }
- };
-
- template <typename Func>
- class find_functor_wrapper: protected cds::details::functor_wrapper<Func>
- {
- typedef cds::details::functor_wrapper<Func> base_class;
- public:
- find_functor_wrapper() {}
- find_functor_wrapper( Func f ): base_class(f) {}
-
- template <typename Q>
- void operator()( value_type& pair, Q const& /*val*/ )
- {
- base_class::get()( pair );
- }
- };
-# endif // ifndef CDS_CXX11_LAMBDA_SUPPORT
- //@endcond
-
public:
/// Forward iterator (see SplitListSet::iterator)
/**
std::pair<bool, bool> ensure( K const& key, Func func )
{
//TODO: pass arguments by reference (make_pair makes copy)
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return base_class::ensure( std::make_pair( key, mapped_type() ),
[&func](bool bNew, value_type& item, value_type const& /*val*/) {
cds::unref(func)( bNew, item );
} );
-# else
- ensure_functor_wrapper<Func> fw( func );
- return base_class::ensure( std::make_pair( key, mapped_type() ), cds::ref(fw) );
-# endif
}
/// Deletes \p key from the map
template <typename K, typename Func>
bool find( K const& key, Func f )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return base_class::find( key, [&f](value_type& pair, K const&){ cds::unref(f)( pair ); } );
-# else
- find_functor_wrapper<Func> fw(f);
- return base_class::find( key, cds::ref(fw) );
-# endif
}
/// Finds the key \p val using \p pred predicate for searching
template <typename K, typename Less, typename Func>
bool find_with( K const& key, Less pred, Func f )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return base_class::find_with( key,
cds::details::predicate_wrapper<value_type, Less, key_accessor>(),
[&f](value_type& pair, K const&){ cds::unref(f)( pair ); } );
-# else
- find_functor_wrapper<Func> fw(f);
- return base_class::find_with( key, cds::details::predicate_wrapper<value_type, Less, key_accessor>(), cds::ref(fw) );
-# endif
}
/// Finds the key \p key
protected:
//@cond
typedef typename base_class::maker::type_traits::key_accessor key_accessor;
-
-# ifndef CDS_CXX11_LAMBDA_SUPPORT
- template <typename Func>
- class ensure_functor_wrapper: protected cds::details::functor_wrapper<Func>
- {
- typedef cds::details::functor_wrapper<Func> base_class;
- public:
- ensure_functor_wrapper() {}
- ensure_functor_wrapper( Func f ): base_class(f) {}
-
- template <typename Q>
- void operator()( bool bNew, value_type& item, const Q& /*val*/ )
- {
- base_class::get()( bNew, item );
- }
- };
-
- template <typename Func>
- class find_functor_wrapper: protected cds::details::functor_wrapper<Func>
- {
- typedef cds::details::functor_wrapper<Func> base_class;
- public:
- find_functor_wrapper() {}
- find_functor_wrapper( Func f ): base_class(f) {}
-
- template <typename Q>
- void operator()( value_type& pair, Q const& /*val*/ )
- {
- base_class::get()( pair );
- }
- };
-# endif // ifndef CDS_CXX11_LAMBDA_SUPPORT
//@endcond
public:
std::pair<bool, bool> ensure( K const& key, Func func )
{
//TODO: pass arguments by reference (make_pair makes copy)
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return base_class::ensure( std::make_pair( key, mapped_type() ),
[&func](bool bNew, value_type& item, value_type const& /*val*/) {
cds::unref(func)( bNew, item );
} );
-# else
- ensure_functor_wrapper<Func> fw( func );
- return base_class::ensure( std::make_pair( key, mapped_type() ), cds::ref(fw) );
-# endif
}
/// Deletes \p key from the map
template <typename K, typename Func>
bool find( K const& key, Func f )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return base_class::find( key, [&f](value_type& pair, K const&){ cds::unref(f)( pair ); } );
-# else
- find_functor_wrapper<Func> fw(f);
- return base_class::find( key, cds::ref(fw) );
-# endif
}
/// Finds the key \p key using \p pred predicate for searching
template <typename K, typename Less, typename Func>
bool find_with( K const& key, Less pred, Func f )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return base_class::find_with( key,
cds::details::predicate_wrapper<value_type, Less, key_accessor>(),
[&f](value_type& pair, K const&){ cds::unref(f)( pair ); } );
-# else
- find_functor_wrapper<Func> fw(f);
- return base_class::find_with( key, cds::details::predicate_wrapper<value_type, Less, key_accessor>(), cds::ref(fw) );
-# endif
}
/// Finds the key \p key
template <typename Q, typename Func>
bool find_( Q& val, Func f )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return base_class::find( val, [&f]( node_type& item, Q& val ) { cds::unref(f)(item.m_Value, val) ; } );
-# else
- find_functor_wrapper<Func> fw(f);
- return base_class::find( val, cds::ref(fw) );
-# endif
}
template <typename Q, typename Less, typename Func>
bool find_with_( Q& val, Less pred, Func f )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return base_class::find_with( val, typename maker::template predicate_wrapper<Less>::type(),
[&f]( node_type& item, Q& val ) { cds::unref(f)(item.m_Value, val) ; } );
-# else
- find_functor_wrapper<Func> fw(f);
- return base_class::find_with( val, typename maker::template predicate_wrapper<Less>::type(), cds::ref(fw) );
-# endif
}
template <typename... Args>
//@endcond
- protected:
- //@cond
-# ifndef CDS_CXX11_LAMBDA_SUPPORT
- template <typename Func>
- class insert_functor_wrapper: protected cds::details::functor_wrapper<Func>
- {
- typedef cds::details::functor_wrapper<Func> base_class;
- public:
- insert_functor_wrapper( Func f ): base_class(f) {}
-
- void operator()(node_type& node)
- {
- base_class::get()( node.m_Value );
- }
- };
-
- template <typename Func, typename Q>
- class ensure_functor_wrapper: protected cds::details::functor_wrapper<Func>
- {
- typedef cds::details::functor_wrapper<Func> base_class;
- Q const& m_val;
- public:
- ensure_functor_wrapper( Func f, Q const& v ): base_class(f), m_val(v) {}
-
- void operator()( bool bNew, node_type& item, node_type const& /*val*/ )
- {
- base_class::get()( bNew, item.m_Value, m_val );
- }
- };
-
- template <typename Func>
- class find_functor_wrapper: protected cds::details::functor_wrapper<Func>
- {
- typedef cds::details::functor_wrapper<Func> base_class;
- public:
- find_functor_wrapper( Func f ): base_class(f) {}
-
- template <typename Q>
- void operator()( node_type& item, Q& val )
- {
- base_class::get()( item.m_Value, val );
- }
- };
-
- template <typename Func>
- class erase_functor_wrapper: protected cds::details::functor_wrapper<Func>
- {
- typedef cds::details::functor_wrapper<Func> base_class;
- public:
- erase_functor_wrapper( Func f ): base_class( f ) {}
-
- void operator()(node_type& node)
- {
- base_class::get()( node.m_Value );
- }
- };
-# endif // ifndef CDS_CXX11_LAMBDA_SUPPORT
- //@endcond
-
protected:
/// Forward iterator
/**
{
scoped_node_ptr pNode( alloc_node( val ));
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
- if ( base_class::insert( *pNode, [&f](node_type& node) { cds::unref(f)( node.m_Value ) ; } ))
-# else
- insert_functor_wrapper<Func> fw(f);
- if ( base_class::insert( *pNode, cds::ref(fw) ) )
-# endif
- {
+ if ( base_class::insert( *pNode, [&f](node_type& node) { cds::unref(f)( node.m_Value ) ; } )) {
pNode.release();
return true;
}
{
scoped_node_ptr pNode( alloc_node( val ));
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
std::pair<bool, bool> bRet = base_class::ensure( *pNode,
[&func, &val]( bool bNew, node_type& item, node_type const& /*val*/ ) {
cds::unref(func)( bNew, item.m_Value, val );
} );
-# else
- ensure_functor_wrapper<Func, Q> fw( func, val );
- std::pair<bool, bool> bRet = base_class::ensure( *pNode, cds::ref(fw) );
-# endif
if ( bRet.first && bRet.second )
pNode.release();
template <typename Q, typename Func>
bool erase( Q const& key, Func f )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return base_class::erase( key, [&f](node_type& node) { cds::unref(f)( node.m_Value ); } );
-# else
- erase_functor_wrapper<Func> fw( f );
- return base_class::erase( key, cds::ref(fw) );
-# endif
}
/// Deletes the item from the set using \p pred predicate for searching
template <typename Q, typename Less, typename Func>
bool erase_with( Q const& key, Less pred, Func f )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return base_class::erase_with( key, typename maker::template predicate_wrapper<Less>::type(),
[&f](node_type& node) { cds::unref(f)( node.m_Value ); } );
-# else
- erase_functor_wrapper<Func> fw( f );
- return base_class::erase_with( key, typename maker::template predicate_wrapper<Less>::type(), cds::ref(fw) );
-# endif
}
/// Extracts the item with specified \p key
}
};
typedef std::unique_ptr< node_type, node_disposer > scoped_node_ptr;
-
//@endcond
- protected:
- //@cond
-# ifndef CDS_CXX11_LAMBDA_SUPPORT
- struct empty_ensure_functor
- {
- void operator()( bool /*bNew*/, node_type& /*item*/, node_type& /*val*/ )
- {}
- };
-# endif
- //@endcond
-
-
public:
/// Initialize split-ordered list of default capacity
/**
{
scoped_node_ptr pNode( alloc_node( val ));
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
std::pair<typename base_class::iterator, bool> ret = base_class::ensure_( *pNode, [](bool /*bNew*/, node_type& /*item*/, node_type& /*val*/){} );
-# else
- std::pair<typename base_class::iterator, bool> ret = base_class::ensure_( *pNode, empty_ensure_functor() );
-# endif
if ( ret.first != base_class::end() && ret.second ) {
pNode.release();
return std::make_pair( iterator(ret.first), ret.second );
template <typename Q, typename Func>
bool find_( Q& val, Func f )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return base_class::find( val, [&f]( node_type& item, Q& val ) { cds::unref(f)(item.m_Value, val) ; } );
-# else
- find_functor_wrapper<Func> fw(f);
- return base_class::find( val, cds::ref(fw) );
-# endif
}
template <typename Q, typename Less, typename Func>
bool find_with_( Q& val, Less pred, Func f )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return base_class::find_with( val, typename maker::template predicate_wrapper<Less>::type(),
[&f]( node_type& item, Q& val ) { cds::unref(f)(item.m_Value, val) ; } );
-# else
- find_functor_wrapper<Func> fw(f);
- return base_class::find_with( val, typename maker::template predicate_wrapper<Less>::type(), cds::ref(fw) );
-# endif
}
return false;
}
-
- //@endcond
-
- protected:
- //@cond
-# ifndef CDS_CXX11_LAMBDA_SUPPORT
- template <typename Func>
- class insert_functor_wrapper: protected cds::details::functor_wrapper<Func>
- {
- typedef cds::details::functor_wrapper<Func> base_class;
- public:
- insert_functor_wrapper( Func f ): base_class(f) {}
-
- void operator()(node_type& node)
- {
- base_class::get()( node.m_Value );
- }
- };
-
- template <typename Func, typename Q>
- class ensure_functor_wrapper: protected cds::details::functor_wrapper<Func>
- {
- typedef cds::details::functor_wrapper<Func> base_class;
- Q const& m_val;
- public:
- ensure_functor_wrapper( Func f, Q const& v ): base_class(f), m_val(v) {}
-
- void operator()( bool bNew, node_type& item, node_type const& /*val*/ )
- {
- base_class::get()( bNew, item.m_Value, m_val );
- }
- };
-
- template <typename Func>
- class find_functor_wrapper: protected cds::details::functor_wrapper<Func>
- {
- typedef cds::details::functor_wrapper<Func> base_class;
- public:
- find_functor_wrapper( Func f ): base_class(f) {}
-
- template <typename Q>
- void operator()( node_type& item, Q& val )
- {
- base_class::get()( item.m_Value, val );
- }
- };
-
- struct empty_find_functor
- {
- template <typename Q>
- void operator()( node_type&, Q& )
- {}
- };
-
- template <typename Func>
- class erase_functor_wrapper: protected cds::details::functor_wrapper<Func>
- {
- typedef cds::details::functor_wrapper<Func> base_class;
- public:
- erase_functor_wrapper( Func f ): base_class( f ) {}
-
- void operator()(node_type& node)
- {
- base_class::get()( node.m_Value );
- }
- };
-# endif // ifndef CDS_CXX11_LAMBDA_SUPPORT
//@endcond
protected:
{
scoped_node_ptr pNode( alloc_node( val ));
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
- if ( base_class::insert( *pNode, [&f](node_type& node) { cds::unref(f)( node.m_Value ) ; } ))
-# else
- insert_functor_wrapper<Func> fw(f);
- if ( base_class::insert( *pNode, cds::ref(fw) ) )
-# endif
- {
+ if ( base_class::insert( *pNode, [&f](node_type& node) { cds::unref(f)( node.m_Value ) ; } )) {
pNode.release();
return true;
}
{
scoped_node_ptr pNode( alloc_node( val ));
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
std::pair<bool, bool> bRet = base_class::ensure( *pNode,
[&func, &val]( bool bNew, node_type& item, node_type const& /*val*/ ) {
cds::unref(func)( bNew, item.m_Value, val );
} );
-# else
- ensure_functor_wrapper<Func, Q> fw( func, val );
- std::pair<bool, bool> bRet = base_class::ensure( *pNode, cds::ref(fw) );
-# endif
-
if ( bRet.first && bRet.second )
pNode.release();
return bRet;
template <typename Q, typename Func>
bool erase( Q const& key, Func f )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return base_class::erase( key, [&f](node_type& node) { cds::unref(f)( node.m_Value ); } );
-# else
- erase_functor_wrapper<Func> fw( f );
- return base_class::erase( key, cds::ref(fw) );
-# endif
}
/// Deletes the item from the set using \p pred predicate for searching
template <typename Q, typename Less, typename Func>
bool erase_with( Q const& key, Less pred, Func f )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return base_class::erase_with( key, typename maker::template predicate_wrapper<Less>::type(),
[&f](node_type& node) { cds::unref(f)( node.m_Value ); } );
-# else
- erase_functor_wrapper<Func> fw( f );
- return base_class::erase_with( key, typename maker::template predicate_wrapper<Less>::type(), cds::ref(fw) );
-# endif
}
/// Extracts an item from the set
#include <cds/container/striped_set/adapter.h>
#include <cds/details/binary_functor_wrapper.h>
-#ifndef CDS_CXX11_LAMBDA_SUPPORT
-# include <cds/details/functor_wrapper.h>
-#endif
-
namespace cds { namespace container {
//@cond
return p.first;
}
};
-
-# ifndef CDS_CXX11_LAMBDA_SUPPORT
-
- template <typename Func>
- class find_functor_wrapper: protected cds::details::functor_wrapper<Func>
- {
- typedef cds::details::functor_wrapper<Func> base_class;
- public:
- find_functor_wrapper() {}
- find_functor_wrapper( Func f ): base_class(f) {}
-
- template <typename Q>
- void operator()( value_type& pair, Q const& /*val*/ )
- {
- base_class::get()( pair );
- }
- };
-
- template <typename Q>
- class insert_value_functor
- {
- Q const& m_val;
- public:
- insert_value_functor( Q const & v)
- : m_val(v)
- {}
-
- void operator()( value_type& item )
- {
- item.second = m_val;
- }
- };
-
- struct dummy_insert_functor
- {
- void operator()( value_type& item )
- {}
- };
-# endif // #ifndef CDS_CXX11_LAMBDA_SUPPORT
-
//@endcond
public:
template <typename K>
bool insert( K const& key )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return insert_key( key, [](value_type&){} );
-# else
- return insert_key( key, dummy_insert_functor() );
-# endif
}
/// Inserts new node
template <typename K, typename V>
bool insert( K const& key, V const& val )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return insert_key( key, [&val](value_type& item) { item.second = val ; } );
-# else
- insert_value_functor<V> f(val);
- return insert_key( key, cds::ref(f) );
-# endif
}
/// Inserts new node and initialize it by a functor
,typename Bucket = bucket_type, typename = typename std::enable_if< Bucket::has_erase_with >::type >
bool erase_with( K const& key, Less pred )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return erase_with( key, pred, [](value_type const&) {} );
-# else
- return erase_with( key, pred, typename base_class::empty_erase_functor() );
-# endif
}
/// Delete \p key from the map
template <typename K, typename Func>
bool find( K const& key, Func f )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return base_class::find( key, [&f]( value_type& pair, K const& ) mutable { cds::unref(f)(pair); } );
-# else
- find_functor_wrapper<Func> fw(f);
- return base_class::find( key, cds::ref(fw) );
-# endif
}
/// Find the key \p val using \p pred predicate
,typename Bucket = bucket_type, typename = typename std::enable_if< Bucket::has_find_with >::type >
bool find_with( K const& key, Less pred, Func f )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return base_class::find_with( key, cds::details::predicate_wrapper< value_type, Less, key_accessor >(),
[&f]( value_type& pair, K const& ) mutable { cds::unref(f)(pair); } );
-# else
- find_functor_wrapper<Func> fw(f);
- return base_class::find_with( key, cds::details::predicate_wrapper< value_type, Less, key_accessor >(), cds::ref(fw) );
-# endif
}
/// Find the key \p key
typedef typename base_class::scoped_resize_lock scoped_resize_lock;
//@endcond
- protected:
- //@cond
-# 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 )
- {}
- };
-# endif
- //@endcond
-
public:
/// Default ctor. The initial capacity is 16.
StripedSet()
template <typename Q>
bool insert( Q const& val )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return insert( val, []( value_type& ) {} );
-# else
- return insert( val, empty_insert_functor() );
-# endif
}
/// Inserts new node
template <typename Q>
bool erase( Q const& key )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return erase( key, [](value_type const&) {} );
-# else
- return erase( key, empty_erase_functor() );
-# endif
}
/// Deletes the item from the set using \p pred predicate for searching
,typename Bucket = bucket_type, typename = typename std::enable_if< Bucket::has_erase_with >::type >
bool erase_with( Q const& key, Less pred )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return erase_with( key, pred, [](value_type const&) {} );
-# else
- return erase_with( key, pred, empty_erase_functor() );
-# endif
}
/// Delete \p key from the set
{}
};
-# ifndef CDS_CXX11_LAMBDA_SUPPORT
- struct copy_construct {
- void operator()( value_type& dest, value_type const& src )
- {
- new ( &dest ) value_type( src );
- }
- };
-# endif
-
typedef cds::details::trivial_assign< value_type, value_type > copy_assign;
typedef typename options::buffer::template rebind<cell_type>::other buffer;
/// @anchor cds_container_VyukovMPMCCycleQueue_enqueue Enqueues \p data to queue
bool enqueue(value_type const& data )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return enqueue( data, [](value_type& dest, value_type const& src){ new ( &dest ) value_type( src ); });
-# else
- return enqueue( data, copy_construct() );
-# endif
}
/// Enqueues data of type \ref cds_container_VyukovMPMCCycleQueue_value_type "value_type" constructed with <tt>std::forward<Args>(args)...</tt>
typedef size_t hash_array[c_nArity] ; ///< hash array
-# 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 )
- {}
- };
-# endif
-
-# if !defined(CDS_CXX11_LAMBDA_SUPPORT) || ((CDS_COMPILER == CDS_COMPILER_MSVC || CDS_COMPILER == CDS_COMPILER_INTEL ) && _MSC_VER == 1600)
- template <typename Disposer>
- class disposer_wrapper: protected cds::details::functor_wrapper<Disposer>
- {
- typedef cds::details::functor_wrapper<Disposer> base_class;
- public:
- disposer_wrapper( Disposer d): base_class(d) {}
-
- void operator()( node_type * pNode )
- {
- base_class::get()( node_traits::to_value_ptr( pNode ));
- }
- };
-# endif
-
struct position {
bucket_iterator itPrev;
bucket_iterator itFound;
*/
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
template <typename Q>
value_type * erase( Q const& val )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return erase( val, [](value_type const&) {} );
-# else
- return erase( val, empty_erase_functor() );
-# endif
}
/// Deletes the item from the set using \p pred predicate for searching
template <typename Q, typename Predicate>
value_type * erase_with( Q const& val, Predicate pred )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return erase_( val, typename predicate_wrapper<Predicate>::type(), [](value_type const&) {} );
-# else
- return erase_( val, typename predicate_wrapper<Predicate>::type(), empty_erase_functor() );
-# endif
}
/// Delete the item from the set
template <typename Q>
bool find( Q const& val )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return find( val, [](value_type&, Q const& ) {} );
-# else
- return find( val, empty_find_functor() );
-# endif
}
/// Find the key \p val using \p pred predicate for comparing
template <typename Q, typename Predicate>
bool find_with( Q const& val, Predicate pred )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return find_with( val, typename predicate_wrapper<Predicate>::type(), [](value_type& , Q const& ) {} );
-# else
- return find_with( val, typename predicate_wrapper<Predicate>::type(), empty_find_functor() );
-# endif
}
/// Clears the set
// locks entire array
scoped_full_lock sl( m_MutexPolicy );
-# if !defined(CDS_CXX11_LAMBDA_SUPPORT) || ((CDS_COMPILER == CDS_COMPILER_MSVC || CDS_COMPILER == CDS_COMPILER_INTEL ) && _MSC_VER == 1600)
- disposer_wrapper<Disposer> disp( oDisposer );
-# endif
for ( unsigned int i = 0; i < c_nArity; ++i ) {
bucket_entry * pEntry = m_BucketTable[i];
bucket_entry * pEnd = pEntry + m_nBucketMask + 1;
for ( ; pEntry != pEnd ; ++pEntry ) {
-# if defined(CDS_CXX11_LAMBDA_SUPPORT) && !((CDS_COMPILER == CDS_COMPILER_MSVC || CDS_COMPILER == CDS_COMPILER_INTEL) && _MSC_VER == 1600)
- // MSVC 10: error to call nested typedefs node_traits from lambda
pEntry->clear( [&oDisposer]( node_type * pNode ){ oDisposer( node_traits::to_value_ptr( pNode )) ; } );
-# else
- pEntry->clear( cds::ref(disp) );
-# endif
}
}
m_ItemCounter.reset();
m_Root.m_pLeft.store( &m_LeafInf1, memory_model::memory_order_relaxed );
m_Root.m_pRight.store( &m_LeafInf2, memory_model::memory_order_release );
}
-
-# ifndef CDS_CXX11_LAMBDA_SUPPORT
- struct trivial_equal_functor {
- template <typename Q>
- bool operator()( Q const& , leaf_node const& ) const
- {
- return true;
- }
- };
-
- struct empty_insert_functor {
- void operator()( value_type& )
- {}
- };
-
- struct assign_guard_functor {
- typename gc::Guard& m_guard;
- assign_guard_functor( typename gc::Guard& guard )
- : m_guard(guard)
- {}
-
- template <typename Q>
- void operator()( value_type& val, Q& )
- {
- m_guard.assign( &val );
- }
-
- void operator()( value_type& val )
- {
- m_guard.assign( &val );
- }
- };
-
-# endif
-
-# if !defined(CDS_CXX11_LAMBDA_SUPPORT) || (CDS_COMPILER == CDS_COMPILER_MSVC && CDS_COMPILER_VERSION == CDS_COMPILER_MSVC10)
- struct unlink_equal_functor {
- bool operator()( value_type const& v, leaf_node const& n ) const
- {
- return &v == node_traits::to_value_ptr( n );
- }
- };
- struct empty_erase_functor {
- void operator()( value_type const& )
- {}
- };
-# endif
//@endcond
public:
*/
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 unlink( value_type& val )
{
-# if defined(CDS_CXX11_LAMBDA_SUPPORT) && !(CDS_COMPILER == CDS_COMPILER_MSVC && CDS_COMPILER_VERSION == CDS_COMPILER_MSVC10)
- // vc10 generates an error for the lambda - it sees cds::intrusive::node_traits but not class-defined node_traits
return erase_( val, node_compare(),
[]( value_type const& v, leaf_node const& n ) -> bool { return &v == node_traits::to_value_ptr( n ); },
[](value_type const&) {} );
-# else
- return erase_( val, node_compare(), unlink_equal_functor(), empty_erase_functor() );
-# endif
}
/// Deletes the item from the tree
template <typename Q>
bool erase( const Q& val )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return erase_( val, node_compare(),
[]( Q const&, leaf_node const& ) -> bool { return true; },
[](value_type const&) {} );
-# else
- return erase_( val, node_compare(), trivial_equal_functor(), empty_erase_functor() );
-# endif
}
/// Delete the item from the tree with comparing functor \p pred
node_traits
> compare_functor;
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return erase_( val, compare_functor(),
[]( Q const&, leaf_node const& ) -> bool { return true; },
[](value_type const&) {} );
-# else
- return erase_( val, compare_functor(), trivial_equal_functor(), empty_erase_functor() );
-# endif
}
/// Deletes the item from the tree
template <typename Q, typename Func>
bool erase( Q const& val, Func f )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return erase_( val, node_compare(),
[]( Q const&, leaf_node const& ) -> bool { return true; },
f );
-# else
- return erase_( val, node_compare(), trivial_equal_functor(), f );
-# endif
}
/// Delete the item from the tree with comparing functor \p pred
node_traits
> compare_functor;
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return erase_( val, compare_functor(),
[]( Q const&, leaf_node const& ) -> bool { return true; },
f );
-# else
- return erase_( val, compare_functor(), trivial_equal_functor(), f );
-# endif
}
/// Extracts an item with minimal key from the tree
template <typename Q>
bool extract_( typename gc::Guard& guard, Q const& key )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return erase_( key, node_compare(),
[]( Q const&, leaf_node const& ) -> bool { return true; },
[&guard]( value_type& found ) { guard.assign( &found ); } );
-# else
- assign_guard_functor f( guard );
- return erase_( key, node_compare(), trivial_equal_functor(), cds::ref(f) );
-# endif
}
template <typename Q, typename Less>
node_traits
> compare_functor;
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return erase_( key, compare_functor(),
[]( Q const&, leaf_node const& ) -> bool { return true; },
[&guard]( value_type& found ) { guard.assign( &found ); } );
-# else
- assign_guard_functor f( guard );
- return erase_( key, compare_functor(), trivial_equal_functor(), cds::ref(f) );
-# endif
}
bool extract_max_( typename gc::Guard& guard )
template <typename Q>
bool get_( typename gc::Guard& guard, Q const& val ) const
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return find_( val, [&guard]( value_type& found, Q const& ) { guard.assign( &found ); } );
-# else
- assign_guard_functor f(guard);
- return find_( val, cds::ref(f) );
-# endif
}
template <typename Q, typename Less>
bool get_with_( typename gc::Guard& guard, Q const& val, Less pred ) const
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return find_with_( val, pred, [&guard]( value_type& found, Q const& ) { guard.assign( &found ); } );
-# else
- assign_guard_functor f(guard);
- return find_with_( val, pred, cds::ref(f) );
-# endif
}
//@endcond
m_Root.m_pLeft.store( &m_LeafInf1, memory_model::memory_order_relaxed );
m_Root.m_pRight.store( &m_LeafInf2, memory_model::memory_order_release );
}
-
-# ifndef CDS_CXX11_LAMBDA_SUPPORT
- struct trivial_equal_functor {
- template <typename Q>
- bool operator()( Q const& , leaf_node const& ) const
- {
- return true;
- }
- };
-
- struct empty_insert_functor {
- void operator()( value_type& )
- {}
- };
-# endif
-# if !defined(CDS_CXX11_LAMBDA_SUPPORT) || (CDS_COMPILER == CDS_COMPILER_MSVC && CDS_COMPILER_VERSION == CDS_COMPILER_MSVC10)
- struct unlink_equal_functor {
- bool operator()( value_type const& v, leaf_node const& n ) const
- {
- return &v == node_traits::to_value_ptr( n );
- }
- };
- struct empty_erase_functor {
- void operator()( value_type const& )
- {}
- };
-# endif
//@endcond
public:
*/
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 unlink( value_type& val )
{
-# if defined(CDS_CXX11_LAMBDA_SUPPORT) && !(CDS_COMPILER == CDS_COMPILER_MSVC && CDS_COMPILER_VERSION == CDS_COMPILER_MSVC10)
- // vc10 generates an error for the lambda - it sees cds::intrusive::node_traits but not class-defined node_traits
return erase_( val, node_compare(),
[]( value_type const& v, leaf_node const& n ) -> bool { return &v == node_traits::to_value_ptr( n ); },
[](value_type const&) {} );
-# else
- return erase_( val, node_compare(), unlink_equal_functor(), empty_erase_functor() );
-# endif
}
/// Deletes the item from the tree
template <typename Q>
bool erase( const Q& val )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return erase_( val, node_compare(),
[]( Q const&, leaf_node const& ) -> bool { return true; },
[](value_type const&) {} );
-# else
- return erase_( val, node_compare(), trivial_equal_functor(), empty_erase_functor() );
-# endif
}
/// Delete the item from the tree with comparing functor \p pred
node_traits
> compare_functor;
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return erase_( val, compare_functor(),
[]( Q const&, leaf_node const& ) -> bool { return true; },
[](value_type const&) {} );
-# else
- return erase_( val, compare_functor(), trivial_equal_functor(), empty_erase_functor() );
-# endif
}
/// Deletes the item from the tree
template <typename Q, typename Func>
bool erase( Q const& val, Func f )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return erase_( val, node_compare(),
[]( Q const&, leaf_node const& ) -> bool { return true; },
f );
-# else
- return erase_( val, node_compare(), trivial_equal_functor(), f );
-# endif
}
/// Delete the item from the tree with comparing functor \p pred
node_traits
> compare_functor;
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return erase_( val, compare_functor(),
[]( Q const&, leaf_node const& ) -> bool { return true; },
f );
-# else
- return erase_( val, compare_functor(), trivial_equal_functor(), f );
-# endif
}
/// Extracts an item with minimal key from the tree
m_pos.unlock();
}
};
-
-# ifndef CDS_CXX11_LAMBDA_SUPPORT
- struct empty_erase_functor {
- void operator()( value_type const & item )
- {}
- };
-# endif
//@endcond
protected:
bool erase_at( node_type * pHead, const Q& val, Compare cmp )
{
position pos;
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return erase_at( pHead, val, cmp, [](value_type const &){}, pos );
-# else
- return erase_at( pHead, val, cmp, empty_erase_functor(), pos );
-# endif
}
template <typename Q, typename Compare>
bool extract_at( node_type * pHead, typename gc::Guard& gp, const Q& val, Compare cmp )
{
position pos;
- if (
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
- erase_at( pHead, val, cmp, [](value_type const &){}, pos )
-# else
- erase_at( pHead, val, cmp, empty_erase_functor(), pos )
-# endif
- )
- {
+ if ( erase_at( pHead, val, cmp, [](value_type const &){}, pos )) {
gp.assign( pos.guards.template get<value_type>(position::guard_current_item) );
return true;
}
};
typedef cds::urcu::details::check_deadlock_policy< gc, rcu_check_deadlock> check_deadlock_policy;
-
-# ifndef CDS_CXX11_LAMBDA_SUPPORT
- struct empty_erase_functor {
- void operator()( value_type const& item )
- {}
- };
-
- struct get_functor {
- value_type * pFound;
-
- get_functor()
- : pFound( nullptr )
- {}
-
- template <typename Q>
- void operator()( value_type& item, Q& val )
- {
- pFound = &item;
- }
- };
-# endif
-
//@endcond
protected:
bool erase_at( node_type * pHead, Q const& val, Compare cmp )
{
position pos;
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return erase_at( pHead, val, cmp, [](value_type const &){}, pos );
-# else
- return erase_at( pHead, val, cmp, empty_erase_functor(), pos );
-# endif
}
template <typename Q, typename Compare>
template <typename Q, typename Compare>
value_type * get_at( node_type * pHead, Q const& val, Compare cmp ) const
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
value_type * pFound = nullptr;
return find_at( pHead, val, cmp, [&pFound](value_type& found, Q const& ) { pFound = &found; } )
? pFound : nullptr;
-# else
- get_functor gf;
- return find_at( pHead, val, cmp, cds::ref( gf ) ) ? gf.pFound : nullptr;
-# endif
}
//@endcond
};
};
-# ifndef CDS_CXX11_LAMBDA_SUPPORT
- struct empty_erase_functor {
- void operator()( value_type const & item )
- {}
- };
-# endif
-
struct clean_disposer {
void operator()( value_type * p )
{
bool erase_at( atomic_node_ptr& refHead, Q const& val, Compare cmp )
{
position pos;
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return erase_at( refHead, val, cmp, [](value_type const&){}, pos );
-# else
- return erase_at( refHead, val, cmp, empty_erase_functor(), pos );
-# endif
}
template <typename Q, typename Compare>
typedef cds::urcu::details::check_deadlock_policy< gc, rcu_check_deadlock> check_deadlock_policy;
-# ifndef CDS_CXX11_LAMBDA_SUPPORT
- struct empty_erase_functor {
- void operator()( value_type const & item )
- {}
- };
-
- struct get_functor {
- value_type * pFound;
-
- get_functor()
- : pFound( nullptr )
- {}
-
- template <typename Q>
- void operator()( value_type& item, Q& val )
- {
- pFound = &item;
- }
- };
-
-# endif
-
static void clear_links( node_type * pNode )
{
pNode->m_pNext.store( marked_node_ptr(), memory_model::memory_order_relaxed );
bool erase_at( atomic_node_ptr& refHead, const Q& val, Compare cmp )
{
position pos;
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return erase_at( refHead, val, cmp, [](value_type const&){}, pos );
-# else
- return erase_at( refHead, val, cmp, empty_erase_functor(), pos );
-# endif
}
template <typename Q, typename Compare >
template <typename Q, typename Compare>
value_type * get_at( atomic_node_ptr& refHead, Q const& val, Compare cmp ) const
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
value_type * pFound = nullptr;
return find_at( refHead, val, cmp,
[&pFound](value_type& found, Q const& ) { pFound = &found; } )
? pFound : nullptr;
-# else
- get_functor gf;
- return find_at( refHead, val, cmp, cds::ref(gf) )
- ? gf.pFound : nullptr;
-# endif
}
template <typename Q, typename Compare>
};
//@endcond
- protected:
- //@cond
-# ifndef CDS_CXX11_LAMBDA_SUPPORT
- struct empty_cleaner
- {
- void operator()( value_type const& ) const
- {}
- };
-# endif
- //@endcond
-
public:
typedef typename traits::buffer::template rebind<node>::other buffer_type ; ///< Heap array buffer type
*/
void clear()
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
clear_with( []( value_type const& src ) {} );
-# else
- clear_with( empty_cleaner() );
-# endif
}
/// Clears the queue (not atomic)
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
node_type * pCur;
};
-# ifndef CDS_CXX11_LAMBDA_SUPPORT
- struct empty_insert_functor {
- void operator()( value_type& )
- {}
- };
-
- struct empty_find_functor {
- template <typename Q>
- void operator()( value_type& item, Q& val )
- {}
- };
-
- 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 );
- }
- };
-
-# endif // ifndef CDS_CXX11_LAMBDA_SUPPORT
-
class head_node: public node_type
{
typename node_type::atomic_ptr m_Tower[c_nMaxHeight];
bTowerOk = true;
}
-# ifndef CDS_CXX11_LAMBDA_SUPPORT
- if ( !insert_at_position( val, pNode, pos, empty_insert_functor() ))
-# else
- if ( !insert_at_position( val, pNode, pos, []( value_type& ) {} ))
-# endif
- {
+ if ( !insert_at_position( val, pNode, pos, []( value_type& ) {} )) {
m_Stat.onInsertRetry();
continue;
}
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;
}
template <typename Q>
value_type * find( Q const& val ) const
{
- node_type * pNode =
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
- find_with_( val, key_comparator(), [](value_type& , Q const& ) {} );
-# else
- find_with_( val, key_comparator(), empty_find_functor() );
-# endif
+ node_type * pNode = find_with_( val, key_comparator(), [](value_type& , Q const& ) {} );
if ( pNode )
return node_traits::to_value_ptr( pNode );
return nullptr;
template <typename Q, typename Less>
value_type * find_with( Q const& val, Less pred ) const
{
- node_type * pNode =
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
- find_with_( val, cds::opt::details::make_comparator_from_less<Less>(), [](value_type& , Q const& ) {} );
-# else
- find_with_( val, cds::opt::details::make_comparator_from_less<Less>(), empty_find_functor() );
-# endif
+ node_type * pNode = find_with_( val, cds::opt::details::make_comparator_from_less<Less>(), [](value_type& , Q const& ) {} );
if ( pNode )
return node_traits::to_value_ptr( pNode );
return nullptr;
};
typedef cds::urcu::details::check_deadlock_policy< gc, rcu_check_deadlock> check_deadlock_policy;
-
-# 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 {
- value_type * pFound;
-
- template <typename Q>
- void operator()( value_type& item, Q& val )
- {
- pFound = &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;
- }
- };
-
-# endif // ifndef CDS_CXX11_LAMBDA_SUPPORT
-
//@endcond
protected:
unsigned int const nHeight = pDel->height();
- if ( try_remove_at( pDel, pos,
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
- [](value_type const&) {}
-# else
- empty_erase_functor()
-# endif
- , true ))
- {
+ if ( try_remove_at( pDel, pos, [](value_type const&) {}, true )) {
--m_ItemCounter;
m_Stat.onRemoveNode( nHeight );
m_Stat.onExtractSuccess();
pDel = pos.pCur;
unsigned int const nHeight = pDel->height();
- if ( try_remove_at( pDel, pos,
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
- [](value_type const&) {}
-# else
- empty_erase_functor()
-# endif
- , true ))
- {
+ if ( try_remove_at( pDel, pos, [](value_type const&) {}, true )) {
--m_ItemCounter;
m_Stat.onRemoveNode( nHeight );
m_Stat.onExtractMinSuccess();
pDel = pos.pCur;
unsigned int const nHeight = pDel->height();
- if ( try_remove_at( pDel, pos,
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
- [](value_type const&) {}
-# else
- empty_erase_functor()
-# endif
- , true ))
- {
+ if ( try_remove_at( pDel, pos, [](value_type const&) {}, true )) {
--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
-
rcu_lock rcuLock;
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;
}
unsigned int nHeight = pDel->height();
- 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
- , false ))
- {
+ if ( node_traits::to_value_ptr( pDel ) == &val && try_remove_at( pDel, pos, [](value_type const&) {}, false )) {
--m_ItemCounter;
m_Stat.onRemoveNode( nHeight );
m_Stat.onUnlinkSuccess();
template <typename Q>
bool erase( const Q& val )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return do_erase( val, key_comparator(), [](value_type const&) {} );
-# else
- return do_erase( val, key_comparator(), empty_erase_functor() );
-# endif
}
/// Delete the item from the set with comparing functor \p pred
template <typename Q, typename Less>
bool erase_with( const Q& val, Less pred )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return do_erase( val, cds::opt::details::make_comparator_from_less<Less>(), [](value_type const&) {} );
-# else
- return do_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 do_find_with( val, key_comparator(), [](value_type& , Q const& ) {} );
-# else
- return do_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 )
{
- return do_find_with( val, cds::opt::details::make_comparator_from_less<Less>(),
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
- [](value_type& , Q const& ) {}
-# else
- empty_find_functor()
-# endif
- );
+ return do_find_with( val, cds::opt::details::make_comparator_from_less<Less>(), [](value_type& , Q const& ) {} );
}
/// Finds the key \p val and return the item found
{
assert( gc::is_locked());
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
value_type * pFound;
return do_find_with( val, key_comparator(), [&pFound](value_type& found, Q const& ) { pFound = &found; } )
? pFound : nullptr;
-# else
- get_functor gf;
- return do_find_with( val, key_comparator(), cds::ref(gf) )
- ? gf.pFound : nullptr;
-# endif
}
/// Finds the key \p val and return the item found
{
assert( gc::is_locked());
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
value_type * pFound;
return do_find_with( val, cds::opt::details::make_comparator_from_less<Less>(),
[&pFound](value_type& found, Q const& ) { pFound = &found; } )
? pFound : nullptr;
-# else
- get_functor gf;
- return do_find_with( val, cds::opt::details::make_comparator_from_less<Less>(), cds::ref(gf) )
- ? gf.pFound : nullptr;
-# endif
}
/// Returns item count in the set
dummy_node_type * pHead = get_bucket( nHash );
assert( pHead != nullptr );
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return m_List.find_at( pHead, sv, cmp,
[&f](value_type& item, split_list::details::search_value_type<Q>& val){ cds::unref(f)(item, val.val ); });
-# else
- split_list::details::find_functor_wrapper<Func> ffw( f );
- return m_List.find_at( pHead, sv, cmp, cds::ref(ffw) );
-# endif
}
template <typename Q, typename Compare>
*/
};
-# ifndef CDS_CXX11_LAMBDA_SUPPORT
- template <typename Func>
- class find_functor_wrapper: protected cds::details::functor_wrapper<Func>
- {
- typedef cds::details::functor_wrapper<Func> base_class;
- public:
- find_functor_wrapper( Func f )
- : base_class( f )
- {}
-
- template <typename ValueType, typename Q>
- void operator()( ValueType& item, split_list::details::search_value_type<Q>& val )
- {
- base_class::get()( item, val.val );
- }
- };
-# endif
-
template <class OrderedList, class Options>
class rebind_list_options
{
split_list::details::search_value_type<Q> sv( val, split_list::regular_hash( nHash ));
dummy_node_type * pHead = get_bucket( nHash );
assert( pHead != nullptr );
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return m_List.find_at( pHead, sv, cmp,
[&f](value_type& item, split_list::details::search_value_type<Q>& val){ cds::unref(f)(item, val.val ); });
-# else
- split_list::details::find_functor_wrapper<Func> ffw( f );
- return m_List.find_at( pHead, sv, cmp, cds::ref(ffw) );
-# endif
}
//@endcond
dummy_node_type * pHead = get_bucket( nHash );
assert( pHead != nullptr );
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return m_List.find_at( pHead, sv, cmp,
[&f](value_type& item, split_list::details::search_value_type<Q>& val){ cds::unref(f)(item, val.val ); });
-# else
- split_list::details::find_functor_wrapper<Func> ffw( f );
- return m_List.find_at( pHead, sv, cmp, cds::ref(ffw) );
-# endif
}
template <typename Q, typename Compare>
typedef typename mutex_policy::scoped_cell_lock scoped_cell_lock;
typedef typename mutex_policy::scoped_full_lock scoped_full_lock;
typedef typename mutex_policy::scoped_resize_lock scoped_resize_lock;
-
-# 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 )
- {}
- };
-# endif
//@endcond
protected:
*/
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
template <typename Q>
value_type * erase( Q const& val )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return erase( val, [](value_type const&) {} );
-# else
- return erase( val, empty_erase_functor() );
-# endif
}
/// Deletes the item from the set using \p pred predicate for searching
template <typename Q, typename Less>
value_type * erase_with( Q const& val, Less pred )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return erase_with( val, pred, [](value_type const&) {} );
-# else
- return erase_with( val, pred, 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( val, [](value_type&, Q const& ) {} );
-# else
- return find( val, empty_find_functor() );
-# endif
}
/// Find the key \p val using \p pred predicate
template <typename Q, typename Less>
bool find_with( Q const& val, Less pred )
{
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
return find_with( val, pred, [](value_type& , Q const& ) {} );
-# else
- return find_with( val, pred, empty_find_functor() );
-# endif
}
/// Clears the set
typedef typename container_type::value_compare key_comparator;
private:
-# ifndef CDS_CXX11_LAMBDA_SUPPORT
- struct empty_insert_functor {
- void operator()( value_type& )
- {}
- };
-# endif
-
container_type m_Set;
public:
{
value_type& val = *itWhat;
from.base_container().erase( itWhat );
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
insert( val, []( value_type& ) {} );
-# else
- insert( val, empty_insert_functor() );
-# endif
}
};
} // namespace details
}
};
-# ifndef CDS_CXX11_LAMBDA_SUPPORT
- struct empty_insert_functor {
- void operator()( value_type& )
- {}
- };
-# endif
-
template <typename Q, typename Pred>
iterator find_key( Q const& key, Pred pred)
{
{
value_type& val = *itWhat;
from.base_container().erase( itWhat );
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
insert( val, []( value_type& ) {} );
-# else
- insert( val, empty_insert_functor() );
-# endif
}
};
return &val;
}
-
-# ifndef CDS_CXX11_LAMBDA_SUPPORT
- struct empty_insert_functor {
- void operator()( value_type& )
- {}
- };
-# endif
-
private:
container_type m_List;
{
value_type& val = *itWhat;
from.base_container().erase( itWhat );
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
insert( val, []( value_type& ) {} );
-# else
- insert( val, empty_insert_functor() );
-# endif
}
};
typedef cds::intrusive::striped_set::load_factor_resizing<256> default_resizing_policy;
private:
-# ifndef CDS_CXX11_LAMBDA_SUPPORT
- struct empty_insert_functor {
- void operator()( value_type& )
- {}
- };
-# endif
-
template <typename Compare>
struct equal_from_compare
{
{
value_type& val = *itWhat;
from.base_container().erase( itWhat );
-# ifdef CDS_CXX11_LAMBDA_SUPPORT
insert( val, []( value_type& ) {} );
-# else
- insert( val, empty_insert_functor() );
-# endif
}
};
/// Operation descriptor used in elimination back-off
typedef treiber_stack::operation< T > operation_desc;
-# if !(defined(CDS_CXX11_LAMBDA_SUPPORT) && !(CDS_COMPILER == CDS_COMPILER_MSVC && CDS_COMPILER_VERSION == CDS_COMPILER_MSVC10))
- struct bkoff_predicate {
- operation_desc * pOp;
- bkoff_predicate( operation_desc * p ): pOp(p) {}
- bool operator()() { return pOp->nStatus.load( atomics::memory_order_acquire ) != op_busy; }
- };
-# endif
-
/// Elimination back-off data
struct elimination_data {
elimination_random_engine randEngine; ///< random engine
}
// Wait for colliding operation
-# if defined(CDS_CXX11_LAMBDA_SUPPORT) && !(CDS_COMPILER == CDS_COMPILER_MSVC && CDS_COMPILER_VERSION == CDS_COMPILER_MSVC10)
- // MSVC++ 2010 compiler error C2065: 'op_busy' : undeclared identifier
bkoff( [&op]() -> bool { return op.nStatus.load( atomics::memory_order_acquire ) != op_busy; } );
-# else
- // Local structs is not supported by old compilers (for example, GCC 4.3)
- //struct bkoff_predicate {
- // operation_desc * pOp;
- // bkoff_predicate( operation_desc * p ): pOp(p) {}
- // bool operator()() { return pOp->nStatus.load( atomics::memory_order_acquire ) != op_busy; }
- //};
- bkoff( bkoff_predicate(&op) );
-# endif
-
{
slot_scoped_lock l( slot.lock );
if ( slot.pRec == myRec )