return false;
}
- /// Ensures that the \p key exists in the map
+ /// Updates the node
/**
The operation performs inserting or changing data with lock-free manner.
- If the \p key not found in the map, then the new item created from \p key
- is inserted into the map (note that in this case the \p key_type should be
- constructible from type \p K).
+ If the item \p val is not found in the map, then \p val is inserted iff \p bAllowInsert is \p true.
Otherwise, the functor \p func is called with item found.
- The functor \p Func may be a function with signature:
- \code
- void func( bool bNew, value_type& item );
- \endcode
- or a functor:
+ The functor \p func signature is:
\code
struct my_functor {
void operator()( bool bNew, value_type& item );
with arguments:
- \p bNew - \p true if the item has been inserted, \p false otherwise
- - \p item - item of the tree
+ - \p item - item of the map
- The functor may change any fields of the \p item.second that is \p value_type.
+ The functor may change any fields of the \p item.second that is \p mapped_type;
+ however, \p func must guarantee that during changing no any other modifications
+ could be made on this item by concurrent threads.
RCU \p synchronize() method can be called. RCU should not be locked.
- Returns <tt> std::pair<bool, bool> </tt> where \p first is \p true if operation is successfull,
+ Returns std::pair<bool, bool> where \p first is \p true if operation is successfull,
+ i.e. the node has been inserted or updated,
\p second is \p true if new item has been added or \p false if the item with \p key
- already is in the tree.
+ already exists.
@warning See \ref cds_intrusive_item_creating "insert item troubleshooting"
*/
template <typename K, typename Func>
- std::pair<bool, bool> ensure( K const& key, Func func )
+ std::pair<bool, bool> update( K const& key, Func func, bool bAllowInsert = true )
{
scoped_node_ptr pNode( cxx_leaf_node_allocator().New( key ));
- std::pair<bool, bool> res = base_class::ensure( *pNode,
- [&func](bool bNew, leaf_node& item, leaf_node const& ){ func( bNew, item.m_Value ); }
+ std::pair<bool, bool> res = base_class::update( *pNode,
+ [&func](bool bNew, leaf_node& item, leaf_node const& ){ func( bNew, item.m_Value ); },
+ bAllowInsert
);
if ( res.first && res.second )
pNode.release();
return res;
}
+ //@cond
+ // Deprecated, use update()
+ template <typename K, typename Func>
+ std::pair<bool, bool> ensure( K const& key, Func func )
+ {
+ return update( key, func, true );
+ }
+ //@endcond
/// Delete \p key from the map
/**\anchor cds_nonintrusive_EllenBinTreeMap_rcu_erase_val
[&f](leaf_node& item, K const& ) { f( item.m_Value );});
}
- /// Find the key \p key
- /** \anchor cds_nonintrusive_EllenBinTreeMap_rcu_find_val
-
+ /// Checks whether the map contains \p key
+ /**
The function searches the item with key equal to \p key
and returns \p true if it is found, and \p false otherwise.
The function applies RCU lock internally.
*/
template <typename K>
+ bool contains( K const& key )
+ {
+ return base_class::contains( key );
+ }
+ //@cond
+ // Deprecated, use contains()
+ template <typename K>
bool find( K const& key )
{
- return base_class::find( key );
+ return contains( key );
}
+ //@endcond
- /// Finds the key \p val using \p pred predicate for searching
+ /// Checks whether the map contains \p key using \p pred predicate for searching
/**
- The function is an analog of \ref cds_nonintrusive_EllenBinTreeMap_rcu_find_val "find(K const&)"
- but \p pred is used for key comparing.
- \p Less functor has the interface like \p std::less.
- \p Less must imply the same element order as the comparator used for building the map.
+ The function is similar to <tt>contains( key )</tt> but \p pred is used for key comparing.
+ \p Less functor has the interface like \p std::less and should meet \ref cds_intrusive_EllenBinTree_rcu_less
+ "Predicate requirements".
+ \p Less must imply the same element order as the comparator used for building the set.
*/
template <typename K, typename Less>
- bool find_with( K const& key, Less pred )
+ bool contains( K const& key, Less pred )
{
CDS_UNUSED( pred );
- return base_class::find_with( key, cds::details::predicate_wrapper< leaf_node, Less, typename maker::key_accessor >() );
+ return base_class::contains( key, cds::details::predicate_wrapper< leaf_node, Less, typename maker::key_accessor >() );
}
+ //@cond
+ // Deprecated, use contains()
+ template <typename K, typename Less>
+ bool find_with( K const& key, Less pred )
+ {
+ return contains( key, pred );
+ }
+ //@endcond
/// Finds \p key and return the item found
/** \anchor cds_nonintrusive_EllenBinTreeMap_rcu_get
return false;
}
- /// Ensures that the item exists in the set
+ /// Updates the node
/**
The operation performs inserting or changing data with lock-free manner.
- If the \p val key not found in the set, then the new item created from \p val
- is inserted into the set. Otherwise, the functor \p func is called with the item found.
- The functor \p Func should be a function with signature:
+ If the item \p val is not found in the set, then \p val is inserted into the set
+ iff \p bAllowInsert is \p true.
+ Otherwise, the functor \p func is called with item found.
+ The functor \p func signature is:
\code
- void func( bool bNew, value_type& item, const Q& val );
+ void func( bool bNew, value_type& item, value_type& val );
\endcode
- or a functor:
- \code
- struct my_functor {
- void operator()( bool bNew, value_type& item, const Q& val );
- };
- \endcode
-
with arguments:
- \p bNew - \p true if the item has been inserted, \p false otherwise
- \p item - item of the set
- - \p val - argument \p key passed into the \p ensure function
+ - \p val - argument \p val passed into the \p %update() function
- The functor may change non-key fields of the \p item; however, \p func must guarantee
+ The functor can change non-key fields of the \p item; however, \p func must guarantee
that during changing no any other modifications could be made on this item by concurrent threads.
- RCU \p synchronize() can be called. RCU should not be locked.
+ RCU \p synchronize method can be called. RCU should not be locked.
- Returns <tt> std::pair<bool, bool> </tt> where \p first is true if operation is successfull,
- \p second is true if new item has been added or \p false if the item with \p key
- already is in the set.
+ Returns std::pair<bool, bool> where \p first is \p true if operation is successfull,
+ i.e. the node has been inserted or updated,
+ \p second is \p true if new item has been added or \p false if the item with \p key
+ already exists.
@warning See \ref cds_intrusive_item_creating "insert item troubleshooting"
*/
template <typename Q, typename Func>
- std::pair<bool, bool> ensure( const Q& val, Func func )
+ std::pair<bool, bool> update( Q const& val, Func func, bool bAllowInsert = true )
{
scoped_node_ptr sp( cxx_leaf_node_allocator().New( val ));
- std::pair<bool, bool> bRes = base_class::ensure( *sp,
- [&func, &val](bool bNew, leaf_node& node, leaf_node&){ func( bNew, node.m_Value, val ); });
+ std::pair<bool, bool> bRes = base_class::update( *sp,
+ [&func, &val](bool bNew, leaf_node& node, leaf_node&){ func( bNew, node.m_Value, val ); },
+ bAllowInsert );
if ( bRes.first && bRes.second )
sp.release();
return bRes;
}
+ //@cond
+ // Deprecated, use update()
+ template <typename Q, typename Func>
+ std::pair<bool, bool> ensure( const Q& val, Func func )
+ {
+ return update( val, func true );
+ }
+ //@endcond
/// Inserts data of type \p value_type created in-place from \p args
/**
}
//@endcond
- /// Find the key \p key
- /** @anchor cds_nonintrusive_EllenBinTreeSet_rcu_find_val
-
+ /// Checks whether the set contains \p key
+ /**
The function searches the item with key equal to \p key
and returns \p true if it is found, and \p false otherwise.
- Note the hash functor specified for class \p Traits template parameter
- should accept a parameter of type \p Q that may be not the same as \ref value_type.
-
The function applies RCU lock internally.
*/
template <typename Q>
+ bool contains( Q const& key ) const
+ {
+ return base_class::contains( key );
+ }
+ //@cond
+ // Deprecated, use contains()
+ template <typename Q>
bool find( Q const& key ) const
{
- return base_class::find( key );
+ return contains( key );
}
+ //@endcond
- /// Finds the key \p key using \p pred predicate for searching
+ /// Checks whether the set contains \p key using \p pred predicate for searching
/**
- The function is an analog of \ref cds_nonintrusive_EllenBinTreeSet_rcu_find_val "find(Q const&)"
- but \p pred is used for key comparing.
- \p Less functor has the interface like \p std::less.
+ The function is similar to <tt>contains( key )</tt> but \p pred is used for key comparing.
+ \p Less functor has the interface like \p std::less and should meet \ref cds_intrusive_EllenBinTree_rcu_less
+ "Predicate requirements".
\p Less must imply the same element order as the comparator used for building the set.
+ \p pred should accept arguments of type \p Q, \p key_type, \p value_type in any combination.
*/
template <typename Q, typename Less>
- bool find_with( Q const& key, Less pred ) const
+ bool contains( Q const& key, Less pred ) const
{
CDS_UNUSED( pred );
- return base_class::find_with( key, cds::details::predicate_wrapper< leaf_node, Less, typename maker::value_accessor >());
+ return base_class::contains( key, cds::details::predicate_wrapper< leaf_node, Less, typename maker::value_accessor >());
+ }
+ //@cond
+ // DEprecated, use contains()
+ template <typename Q, typename Less>
+ bool find_with( Q const& key, Less pred ) const
+ {
+ return contains( key, pred );
}
+ //@endcond
/// Finds \p key and return the item found
/** \anchor cds_nonintrusive_EllenBinTreeSet_rcu_get
return false;
}
- /// Ensures that the \p key exists in the map
+ /// Updates the node
/**
The operation performs inserting or changing data with lock-free manner.
- If the \p key not found in the map, then the new item created from \p key
- is inserted into the map (note that in this case the \ref key_type should be
- constructible from type \p K).
+ If the item \p val is not found in the map, then \p val is inserted iff \p bAllowInsert is \p true.
Otherwise, the functor \p func is called with item found.
- The functor \p Func may be a function with signature:
- \code
- void func( bool bNew, value_type& item );
- \endcode
- or a functor:
+ The functor \p func signature is:
\code
struct my_functor {
void operator()( bool bNew, value_type& item );
with arguments:
- \p bNew - \p true if the item has been inserted, \p false otherwise
- - \p item - item of the list
+ - \p item - item of the map
- The functor may change any fields of the \p item.second that is \ref value_type.
+ The functor may change any fields of the \p item.second that is \ref mapped_type;
+ however, \p func must guarantee that during changing no any other modifications
+ could be made on this item by concurrent threads.
- Returns <tt> std::pair<bool, bool> </tt> where \p first is true if operation is successfull,
- \p second is true if new item has been added or \p false if the item with \p key
- already is in the list.
+ Returns std::pair<bool, bool> where \p first is \p true if operation is successfull,
+ i.e. the node has been inserted or updated,
+ \p second is \p true if new item has been added or \p false if the item with \p key
+ already exists.
@warning See \ref cds_intrusive_item_creating "insert item troubleshooting"
*/
template <typename K, typename Func>
- std::pair<bool, bool> ensure( K const& key, Func func )
+ std::pair<bool, bool> update( K const& key, Func func, bool bAllowInsert = true )
{
scoped_node_ptr pNode( cxx_leaf_node_allocator().New( key ));
- std::pair<bool, bool> res = base_class::ensure( *pNode,
- [&func](bool bNew, leaf_node& item, leaf_node const& ){ func( bNew, item.m_Value ); }
+ std::pair<bool, bool> res = base_class::update( *pNode,
+ [&func](bool bNew, leaf_node& item, leaf_node const& ){ func( bNew, item.m_Value ); },
+ bAllowInsert
);
if ( res.first && res.second )
pNode.release();
return res;
}
+ //@cond
+ // Deprecated, use update()
+ template <typename K, typename Func>
+ std::pair<bool, bool> ensure( K const& key, Func func )
+ {
+ return update( key, func, true );
+ }
+ //@endcond
/// Delete \p key from the map
/**\anchor cds_nonintrusive_EllenBinTreeMap_erase_val
[&f](leaf_node& item, K const& ) { f( item.m_Value );});
}
- /// Find the key \p key
- /** \anchor cds_nonintrusive_EllenBinTreeMap_find_val
-
+ /// Checks whether the map contains \p key
+ /**
The function searches the item with key equal to \p key
and returns \p true if it is found, and \p false otherwise.
*/
template <typename K>
+ bool contains( K const& key )
+ {
+ return base_class::contains( key );
+ }
+ //@cond
+ // Deprecated, use contains()
+ template <typename K>
bool find( K const& key )
{
- return base_class::find( key );
+ return contains( key );
}
+ //@endcond
- /// Finds the key \p val using \p pred predicate for searching
+ /// Checks whether the map contains \p key using \p pred predicate for searching
/**
- The function is an analog of \ref cds_nonintrusive_EllenBinTreeMap_find_val "find(K const&)"
- but \p pred is used for key comparing.
+ The function is similar to <tt>contains( key )</tt> but \p pred is used for key comparing.
\p Less functor has the interface like \p std::less.
- \p Less must imply the same element order as the comparator used for building the map.
+ \p Less must imply the same element order as the comparator used for building the set.
*/
template <typename K, typename Less>
- bool find_with( K const& key, Less pred )
+ bool contains( K const& key, Less pred )
{
CDS_UNUSED( pred );
- return base_class::find_with( key, cds::details::predicate_wrapper< leaf_node, Less, typename maker::key_accessor >() );
+ return base_class::contains( key, cds::details::predicate_wrapper< leaf_node, Less, typename maker::key_accessor >() );
}
+ //@cond
+ // Deprecated, use contains()
+ template <typename K, typename Less>
+ bool find_with( K const& key, Less pred )
+ {
+ return contains( key, pred );
+ }
+ //@endcond
/// Finds \p key and returns the item found
/** @anchor cds_nonintrusive_EllenBinTreeMap_get
return false;
}
- /// Ensures that the item exists in the set
+ /// Updates the node
/**
The operation performs inserting or changing data with lock-free manner.
- If the \p val key not found in the set, then the new item created from \p val
- is inserted into the set. Otherwise, the functor \p func is called with the item found.
- The functor \p Func should be a function with signature:
- \code
- void func( bool bNew, value_type& item, const Q& val );
- \endcode
- or a functor:
+ If the item \p val is not found in the set, then \p val is inserted into the set
+ iff \p bAllowInsert is \p true.
+ Otherwise, the functor \p func is called with item found.
+ The functor \p func signature is:
\code
struct my_functor {
void operator()( bool bNew, value_type& item, const Q& val );
};
\endcode
-
+ with arguments:
with arguments:
- \p bNew - \p true if the item has been inserted, \p false otherwise
- \p item - item of the set
- - \p val - argument \p key passed into the \p ensure function
+ - \p val - argument \p key passed into the \p %update() function
- The functor may change non-key fields of the \p item; however, \p func must guarantee
+ The functor can change non-key fields of the \p item; however, \p func must guarantee
that during changing no any other modifications could be made on this item by concurrent threads.
- Returns <tt> std::pair<bool, bool> </tt> where \p first is true if operation is successfull,
- \p second is true if new item has been added or \p false if the item with \p key
- already is in the set.
+ Returns std::pair<bool, bool> where \p first is \p true if operation is successfull,
+ i.e. the node has been inserted or updated,
+ \p second is \p true if new item has been added or \p false if the item with \p key
+ already exists.
@warning See \ref cds_intrusive_item_creating "insert item troubleshooting"
*/
template <typename Q, typename Func>
- std::pair<bool, bool> ensure( const Q& val, Func func )
+ std::pair<bool, bool> update( const Q& val, Func func, bool bAllowInsert = true )
{
scoped_node_ptr sp( cxx_leaf_node_allocator().New( val ));
- std::pair<bool, bool> bRes = base_class::ensure( *sp,
- [&func, &val](bool bNew, leaf_node& node, leaf_node&){ func( bNew, node.m_Value, val ); });
+ std::pair<bool, bool> bRes = base_class::update( *sp,
+ [&func, &val](bool bNew, leaf_node& node, leaf_node&){ func( bNew, node.m_Value, val ); },
+ bAllowInsert );
if ( bRes.first && bRes.second )
sp.release();
return bRes;
}
+ //@cond
+ // Deprecated, use update()
+ template <typename Q, typename Func>
+ std::pair<bool, bool> ensure( const Q& val, Func func )
+ {
+ return update( val, func, true );
+ }
+ //@endcond
/// Inserts data of type \p value_type created in-place from \p args
/**
}
//@endcond
- /// Find the key \p key
- /** @anchor cds_nonintrusive_EllenBinTreeSet_find_val
-
+ /// Checks whether the set contains \p key
+ /**
The function searches the item with key equal to \p key
and returns \p true if it is found, and \p false otherwise.
-
- Note the hash functor specified for class \p Traits template parameter
- should accept a parameter of type \p Q that may be not the same as \ref value_type.
*/
template <typename Q>
+ bool contains( Q const & key )
+ {
+ return base_class::contains( key );
+ }
+ //@cond
+ // Deprecated, use contains()
+ template <typename Q>
bool find( Q const & key )
{
- return base_class::find( key );
+ return contains( key );
}
+ //@endcond
- /// Finds the key \p key using \p pred predicate for searching
+ /// Checks whether the set contains \p key using \p pred predicate for searching
/**
- The function is an analog of \ref cds_nonintrusive_EllenBinTreeSet_find_val "find(Q const&)"
- but \p pred is used for key comparing.
+ The function is similar to <tt>contains( key )</tt> but \p pred is used for key comparing.
\p Less functor has the interface like \p std::less.
\p Less must imply the same element order as the comparator used for building the set.
*/
template <typename Q, typename Less>
- bool find_with( Q const& key, Less pred )
+ bool contains( Q const& key, Less pred )
{
CDS_UNUSED( pred );
- return base_class::find_with( key, cds::details::predicate_wrapper< leaf_node, Less, typename maker::value_accessor >());
+ return base_class::contains( key, cds::details::predicate_wrapper< leaf_node, Less, typename maker::value_accessor >());
}
+ //@cond
+ // Deprecated, use contains()
+ template <typename Q, typename Less>
+ bool find_with( Q const& key, Less pred )
+ {
+ return contains( key, pred );
+ }
+ //@endcond
/// Finds \p key and returns the item found
/** @anchor cds_nonintrusive_EllenBinTreeSet_get
return true;
}
- /// Ensures that the \p val exists in the tree
+ /// Updates the node
/**
The operation performs inserting or changing data with lock-free manner.
- If the item \p val is not found in the tree, then \p val is inserted into the tree.
+ If the item \p val is not found in the set, then \p val is inserted into the set
+ iff \p bAllowInsert is \p true.
Otherwise, the functor \p func is called with item found.
- The functor signature is:
+ The functor \p func signature is:
\code
void func( bool bNew, value_type& item, value_type& val );
\endcode
with arguments:
- \p bNew - \p true if the item has been inserted, \p false otherwise
- - \p item - item of the tree
- - \p val - argument \p val passed into the \p ensure function
+ - \p item - item of the set
+ - \p val - argument \p val passed into the \p %update() function
If new item has been inserted (i.e. \p bNew is \p true) then \p item and \p val arguments
refer to the same thing.
RCU \p synchronize method can be called. RCU should not be locked.
- Returns <tt>std::pair<bool, bool> </tt> where \p first is \p true if operation is successfull,
+ Returns std::pair<bool, bool> where \p first is \p true if operation is successfull,
+ i.e. the node has been inserted or updated,
\p second is \p true if new item has been added or \p false if the item with \p key
- already is in the tree.
+ already exists.
@warning See \ref cds_intrusive_item_creating "insert item troubleshooting"
*/
template <typename Func>
- std::pair<bool, bool> ensure( value_type& val, Func func )
+ std::pair<bool, bool> update( value_type& val, Func func, bool bAllowInsert = true )
{
check_deadlock_policy::check();
if ( res.updParent.bits() != update_desc::Clean )
help( res.updParent, updRetire );
else {
+ if ( !bAllowInsert )
+ return std::make_pair( false, false );
+
if ( !pNewInternal.get() )
pNewInternal.reset( alloc_internal_node() );
return std::make_pair( true, true );
}
+ //@cond
+ // Deprecated, use update()
+ template <typename Func>
+ std::pair<bool, bool> ensure( value_type& val, Func func )
+ {
+ return update( val, func, true );
+ }
+ //@endcond
/// Unlinks the item \p val from the tree
/**
return exempt_ptr( extract_with_( key, pred ));
}
- /// Finds the key \p key
- /** @anchor cds_intrusive_EllenBinTree_rcu_find_val
+ /// Checks whether the set contains \p key
+ /**
The function searches the item with key equal to \p key
and returns \p true if it is found, and \p false otherwise.
- Note the hash functor specified for class \p Traits template parameter
- should accept a parameter of type \p Q that can be not the same as \p value_type.
-
The function applies RCU lock internally.
*/
template <typename Q>
- bool find( Q const& key ) const
+ bool contains( Q const& key ) const
{
rcu_lock l;
search_result res;
m_Stat.onFindFailed();
return false;
}
+ //@cond
+ // Deprecated, use contains()
+ template <typename Q>
+ bool find( Q const& key ) const
+ {
+ return contains( key );
+ }
+ //@endcond
- /// Finds the key \p key with comparing functor \p pred
+ /// Checks whether the set contains \p key using \p pred predicate for searching
/**
- The function is an analog of \ref cds_intrusive_EllenBinTree_rcu_find_val "find(Q const&)"
- but \p pred is used for key compare.
+ The function is similar to <tt>contains( key )</tt> but \p pred is used for key comparing.
\p Less functor has the interface like \p std::less and should meet \ref cds_intrusive_EllenBinTree_rcu_less
"Predicate requirements".
- \p pred must imply the same element order as the comparator used for building the tree.
+ \p Less must imply the same element order as the comparator used for building the set.
\p pred should accept arguments of type \p Q, \p key_type, \p value_type in any combination.
*/
template <typename Q, typename Less>
- bool find_with( Q const& key, Less pred ) const
+ bool contains( Q const& key, Less pred ) const
{
CDS_UNUSED( pred );
typedef ellen_bintree::details::compare<
m_Stat.onFindFailed();
return false;
}
+ //@cond
+ // Deprecated, use contains()
+ template <typename Q, typename Less>
+ bool find_with( Q const& key, Less pred ) const
+ {
+ return contains( key, pred );
+ }
+ //@endcond
/// Finds the key \p key
/** @anchor cds_intrusive_EllenBinTree_rcu_find_func
return true;
}
- /// Ensures that the \p val exists in the tree
+ /// Updates the node
/**
The operation performs inserting or changing data with lock-free manner.
- If the item \p val is not found in the tree, then \p val is inserted into the tree.
+ If the item \p val is not found in the set, then \p val is inserted into the set
+ iff \p bAllowInsert is \p true.
Otherwise, the functor \p func is called with item found.
- The functor signature is:
+ The functor \p func signature is:
\code
void func( bool bNew, value_type& item, value_type& val );
\endcode
with arguments:
- \p bNew - \p true if the item has been inserted, \p false otherwise
- - \p item - an item of the tree
- - \p val - the argument \p val passed to the \p ensure function
+ - \p item - item of the set
+ - \p val - argument \p val passed into the \p %update() function
If new item has been inserted (i.e. \p bNew is \p true) then \p item and \p val arguments
refer to the same thing.
that during changing no any other modifications could be made on this item by concurrent threads.
Returns std::pair<bool, bool> where \p first is \p true if operation is successfull,
+ i.e. the node has been inserted or updated,
\p second is \p true if new item has been added or \p false if the item with \p key
- already is in the tree.
+ already exists.
@warning See \ref cds_intrusive_item_creating "insert item troubleshooting"
*/
template <typename Func>
- std::pair<bool, bool> ensure( value_type& val, Func func )
+ std::pair<bool, bool> update( value_type& val, Func func, bool bAllowInsert = true )
{
typename gc::Guard guardInsert;
guardInsert.assign( &val );
}
if ( res.updGrandParent.bits() == update_desc::Clean && res.updParent.bits() == update_desc::Clean ) {
+ if ( !bAllowInsert )
+ return std::make_pair( false, false );
if ( !pNewInternal.get() )
pNewInternal.reset( alloc_internal_node() );
m_Stat.onEnsureNew();
return std::make_pair( true, true );
}
+ //@cond
+ // Deprecated, us update()
+ template <typename Func>
+ std::pair<bool, bool> ensure( value_type& val, Func func )
+ {
+ return update( val, func, true );
+ }
+ //@endcond
/// Unlinks the item \p val from the tree
/**
return gp;
}
- /// Finds the key \p key
- /** @anchor cds_intrusive_EllenBinTree_find_val
+ /// Checks whether the set contains \p key
+ /**
The function searches the item with key equal to \p key
and returns \p true if it is found, and \p false otherwise.
-
- Note the hash functor specified for class \p Traits template parameter
- should accept a parameter of type \p Q that can be not the same as \p value_type.
*/
template <typename Q>
- bool find( Q const& key ) const
+ bool contains( Q const& key ) const
{
search_result res;
if ( search( res, key, node_compare() )) {
m_Stat.onFindFailed();
return false;
}
+ //@cond
+ // Deprecated, use contains()
+ template <typename Q>
+ bool find( Q const& key ) const
+ {
+ return contains( key );
+ }
+ //@endcond
- /// Finds the key \p key with comparing functor \p pred
+ /// Checks whether the set contains \p key using \p pred predicate for searching
/**
- The function is an analog of \ref cds_intrusive_EllenBinTree_find_val "find(Q const&)"
- but \p pred is used for key compare.
- \p Less functor has the interface like \p std::less and should meet \ref cds_intrusive_EllenBinTree_less
- "Predicate requirements".
- \p pred must imply the same element order as the comparator used for building the tree.
- \p pred should accept arguments of type \p Q, \p key_type, \p value_type in any combination.
+ The function is similar to <tt>contains( key )</tt> but \p pred is used for key comparing.
+ \p Less functor has the interface like \p std::less.
+ \p Less must imply the same element order as the comparator used for building the set.
*/
template <typename Q, typename Less>
- bool find_with( Q const& key, Less pred ) const
+ bool contains( Q const& key, Less pred ) const
{
CDS_UNUSED( pred );
typedef ellen_bintree::details::compare<
m_Stat.onFindFailed();
return false;
}
+ //@cond
+ // Deprecated, use contains()
+ template <typename Q, typename Less>
+ bool find_with( Q const& key, Less pred ) const
+ {
+ return contains( key, pred );
+ }
+ //@endcond
/// Finds the key \p key
/** @anchor cds_intrusive_EllenBinTree_find_func
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='DebugVLD|x64'">true</ExcludedFromBuild>\r
</ClCompile>\r
<ClCompile Include="..\..\..\tests\unit\map2\map_delodd_ellentree.cpp">\r
- <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='DebugVLD|x64'">true</ExcludedFromBuild>\r
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='DebugVLD|x64'">false</ExcludedFromBuild>\r
</ClCompile>\r
<ClCompile Include="..\..\..\tests\unit\map2\map_delodd_michael.cpp">\r
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='DebugVLD|x64'">false</ExcludedFromBuild>\r
#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
# define CDSUNIT_DECLARE_EllenBinTreeMap_RCU_signal \
- CDSUNIT_DECLARE_TEST(EllenBinTreeMap_rcu_shb)\
- CDSUNIT_DECLARE_TEST(EllenBinTreeMap_rcu_shb_stat)\
- CDSUNIT_DECLARE_TEST(EllenBinTreeMap_rcu_sht)\
- CDSUNIT_DECLARE_TEST(EllenBinTreeMap_rcu_sht_stat)
-
-# define CDSUNIT_DEFINE_EllenBinTreeMap_RCU_signal( IMPL, C ) \
- TEST_MAP_NOLF_EXTRACT(IMPL, C, EllenBinTreeMap_rcu_shb)\
- TEST_MAP_NOLF_EXTRACT(IMPL, C, EllenBinTreeMap_rcu_shb_stat)\
- TEST_MAP_NOLF_EXTRACT(IMPL, C, EllenBinTreeMap_rcu_sht)\
- TEST_MAP_NOLF_EXTRACT(IMPL, C, EllenBinTreeMap_rcu_sht_stat)
+ TEST_CASE(tag_EllenBinTreeMap, EllenBinTreeMap_rcu_shb)\
+ TEST_CASE(tag_EllenBinTreeMap, EllenBinTreeMap_rcu_shb_stat)\
+ TEST_CASE(tag_EllenBinTreeMap, EllenBinTreeMap_rcu_sht)\
+ TEST_CASE(tag_EllenBinTreeMap, EllenBinTreeMap_rcu_sht_stat)
# define CDSUNIT_TEST_EllenBinTreeMap_RCU_signal \
CPPUNIT_TEST(EllenBinTreeMap_rcu_shb)\
CPPUNIT_TEST(EllenBinTreeMap_rcu_sht_stat)
#else
# define CDSUNIT_DECLARE_EllenBinTreeMap_RCU_signal
-# define CDSUNIT_DEFINE_EllenBinTreeMap_RCU_signal( IMPL, C )
# define CDSUNIT_TEST_EllenBinTreeMap_RCU_signal
#endif
#define CDSUNIT_DECLARE_EllenBinTreeMap \
- CDSUNIT_DECLARE_TEST(EllenBinTreeMap_hp)\
- CDSUNIT_DECLARE_TEST(EllenBinTreeMap_hp_yield)\
- CDSUNIT_DECLARE_TEST(EllenBinTreeMap_hp_stat)\
- CDSUNIT_DECLARE_TEST(EllenBinTreeMap_dhp)\
- CDSUNIT_DECLARE_TEST(EllenBinTreeMap_dhp_yield)\
- CDSUNIT_DECLARE_TEST(EllenBinTreeMap_dhp_stat)\
- CDSUNIT_DECLARE_TEST(EllenBinTreeMap_rcu_gpi)\
- CDSUNIT_DECLARE_TEST(EllenBinTreeMap_rcu_gpi_stat)\
- CDSUNIT_DECLARE_TEST(EllenBinTreeMap_rcu_gpb)\
- CDSUNIT_DECLARE_TEST(EllenBinTreeMap_rcu_gpb_yield)\
- CDSUNIT_DECLARE_TEST(EllenBinTreeMap_rcu_gpb_stat)\
- CDSUNIT_DECLARE_TEST(EllenBinTreeMap_rcu_gpt)\
- CDSUNIT_DECLARE_TEST(EllenBinTreeMap_rcu_gpt_stat)\
+ TEST_CASE(tag_EllenBinTreeMap, EllenBinTreeMap_hp)\
+ TEST_CASE(tag_EllenBinTreeMap, EllenBinTreeMap_hp_yield)\
+ TEST_CASE(tag_EllenBinTreeMap, EllenBinTreeMap_hp_stat)\
+ TEST_CASE(tag_EllenBinTreeMap, EllenBinTreeMap_dhp)\
+ TEST_CASE(tag_EllenBinTreeMap, EllenBinTreeMap_dhp_yield)\
+ TEST_CASE(tag_EllenBinTreeMap, EllenBinTreeMap_dhp_stat)\
+ TEST_CASE(tag_EllenBinTreeMap, EllenBinTreeMap_rcu_gpi)\
+ TEST_CASE(tag_EllenBinTreeMap, EllenBinTreeMap_rcu_gpi_stat)\
+ TEST_CASE(tag_EllenBinTreeMap, EllenBinTreeMap_rcu_gpb)\
+ TEST_CASE(tag_EllenBinTreeMap, EllenBinTreeMap_rcu_gpb_yield)\
+ TEST_CASE(tag_EllenBinTreeMap, EllenBinTreeMap_rcu_gpb_stat)\
+ TEST_CASE(tag_EllenBinTreeMap, EllenBinTreeMap_rcu_gpt)\
+ TEST_CASE(tag_EllenBinTreeMap, EllenBinTreeMap_rcu_gpt_stat)\
CDSUNIT_DECLARE_EllenBinTreeMap_RCU_signal
-#define CDSUNIT_DEFINE_EllenBinTreeMap( IMPL, C ) \
- TEST_MAP_NOLF_EXTRACT(IMPL, C, EllenBinTreeMap_hp)\
- TEST_MAP_NOLF_EXTRACT(IMPL, C, EllenBinTreeMap_hp_yield)\
- TEST_MAP_NOLF_EXTRACT(IMPL, C, EllenBinTreeMap_hp_stat)\
- TEST_MAP_NOLF_EXTRACT(IMPL, C, EllenBinTreeMap_dhp)\
- TEST_MAP_NOLF_EXTRACT(IMPL, C, EllenBinTreeMap_dhp_yield)\
- TEST_MAP_NOLF_EXTRACT(IMPL, C, EllenBinTreeMap_dhp_stat)\
- TEST_MAP_NOLF_EXTRACT(IMPL, C, EllenBinTreeMap_rcu_gpi)\
- TEST_MAP_NOLF_EXTRACT(IMPL, C, EllenBinTreeMap_rcu_gpi_stat)\
- TEST_MAP_NOLF_EXTRACT(IMPL, C, EllenBinTreeMap_rcu_gpb)\
- TEST_MAP_NOLF_EXTRACT(IMPL, C, EllenBinTreeMap_rcu_gpb_yield)\
- TEST_MAP_NOLF_EXTRACT(IMPL, C, EllenBinTreeMap_rcu_gpb_stat)\
- TEST_MAP_NOLF_EXTRACT(IMPL, C, EllenBinTreeMap_rcu_gpt)\
- TEST_MAP_NOLF_EXTRACT(IMPL, C, EllenBinTreeMap_rcu_gpt_stat)\
- CDSUNIT_DEFINE_EllenBinTreeMap_RCU_signal( IMPL, C )
-
#define CDSUNIT_TEST_EllenBinTreeMap \
CPPUNIT_TEST(EllenBinTreeMap_hp)\
CPPUNIT_TEST(EllenBinTreeMap_hp_yield)\
CDSUNIT_DECLARE_MichaelMap
CDSUNIT_DECLARE_SplitList
CDSUNIT_DECLARE_SkipListMap
+ CDSUNIT_DECLARE_EllenBinTreeMap
// This test is not suitable for MultiLevelHashMap
//CDSUNIT_DECLARE_MultiLevelHashMap
CDSUNIT_TEST_MichaelMap
CDSUNIT_TEST_SplitList
CDSUNIT_TEST_SkipListMap
+ CDSUNIT_TEST_EllenBinTreeMap
//CDSUNIT_TEST_MultiLevelHashMap // the test is not suitable
CPPUNIT_TEST_SUITE_END();
////CDSUNIT_DECLARE_StripedMap
////CDSUNIT_DECLARE_RefinableMap
//CDSUNIT_DECLARE_CuckooMap
- //CDSUNIT_DECLARE_EllenBinTreeMap
//CDSUNIT_DECLARE_BronsonAVLTreeMap
//CDSUNIT_DECLARE_MultiLevelHashMap
////CDSUNIT_DECLARE_StdMap
#include "map2/map_delodd.h"
#include "map2/map_type_ellen_bintree.h"
-namespace map2 {
- CDSUNIT_DEFINE_EllenBinTreeMap( cc::ellen_bintree::implementation_tag, Map_DelOdd)
+#undef TEST_CASE
+#define TEST_CASE(TAG, X) void Map_DelOdd::X() { run_test<typename map_type< TAG, key_type, value_type>::X>(); }
+#include "map2/map_defs.h"
- CPPUNIT_TEST_SUITE_PART( Map_DelOdd, run_EllenBinTreeMap )
- CDSUNIT_TEST_EllenBinTreeMap
- CPPUNIT_TEST_SUITE_END_PART()
+namespace map2 {
+ CDSUNIT_DECLARE_EllenBinTreeMap
} // namespace map2
namespace map2 {
+ template <class GC, typename Key, typename T, typename Traits = cc::ellen_bintree::traits >
+ class EllenBinTreeMap : public cc::EllenBinTreeMap< GC, Key, T, Traits >
+ {
+ typedef cc::EllenBinTreeMap< GC, Key, T, Traits > base_class;
+ public:
+ template <typename Config>
+ EllenBinTreeMap( Config const& /*cfg*/)
+ : base_class()
+ {}
+
+ // for testing
+ static CDS_CONSTEXPR bool const c_bExtractSupported = true;
+ static CDS_CONSTEXPR bool const c_bLoadFactorDepended = false;
+ };
+
+ struct tag_EllenBinTreeMap;
+
template <typename Key, typename Value>
- struct map_type< cc::ellen_bintree::implementation_tag, Key, Value >: public map_type_base< Key, Value >
+ struct map_type< tag_EllenBinTreeMap, Key, Value >: public map_type_base< Key, Value >
{
typedef map_type_base< Key, Value > base_class;
typedef typename base_class::compare compare;
struct traits_EllenBinTreeMap_hp : traits_EllenBinTreeMap {
typedef cds::memory::pool_allocator< typename ellen_bintree_props::hp_gc::update_desc, ellen_bintree_pool::update_desc_pool_accessor > update_desc_allocator;
};
- typedef cc::EllenBinTreeMap< cds::gc::HP, Key, Value, traits_EllenBinTreeMap_hp >EllenBinTreeMap_hp;
+ typedef EllenBinTreeMap< cds::gc::HP, Key, Value, traits_EllenBinTreeMap_hp >EllenBinTreeMap_hp;
struct traits_EllenBinTreeMap_dhp : traits_EllenBinTreeMap {
typedef cds::memory::pool_allocator< typename ellen_bintree_props::dhp_gc::update_desc, ellen_bintree_pool::update_desc_pool_accessor > update_desc_allocator;
};
- typedef cc::EllenBinTreeMap< cds::gc::DHP, Key, Value, traits_EllenBinTreeMap_dhp >EllenBinTreeMap_dhp;
+ typedef EllenBinTreeMap< cds::gc::DHP, Key, Value, traits_EllenBinTreeMap_dhp >EllenBinTreeMap_dhp;
struct traits_EllenBinTreeMap_gpi : traits_EllenBinTreeMap {
typedef cds::memory::pool_allocator< typename ellen_bintree_props::gpi::update_desc, ellen_bintree_pool::update_desc_pool_accessor > update_desc_allocator;
};
- typedef cc::EllenBinTreeMap< rcu_gpi, Key, Value, traits_EllenBinTreeMap_gpi >EllenBinTreeMap_rcu_gpi;
+ typedef EllenBinTreeMap< rcu_gpi, Key, Value, traits_EllenBinTreeMap_gpi >EllenBinTreeMap_rcu_gpi;
struct traits_EllenBinTreeMap_gpb : traits_EllenBinTreeMap {
typedef cds::memory::pool_allocator< typename ellen_bintree_props::gpb::update_desc, ellen_bintree_pool::update_desc_pool_accessor > update_desc_allocator;
};
- typedef cc::EllenBinTreeMap< rcu_gpb, Key, Value, traits_EllenBinTreeMap_gpb >EllenBinTreeMap_rcu_gpb;
+ typedef EllenBinTreeMap< rcu_gpb, Key, Value, traits_EllenBinTreeMap_gpb >EllenBinTreeMap_rcu_gpb;
struct traits_EllenBinTreeMap_gpt : traits_EllenBinTreeMap {
typedef cds::memory::pool_allocator< typename ellen_bintree_props::gpt::update_desc, ellen_bintree_pool::update_desc_pool_accessor > update_desc_allocator;
};
- typedef cc::EllenBinTreeMap< rcu_gpt, Key, Value, traits_EllenBinTreeMap_gpt >EllenBinTreeMap_rcu_gpt;
+ typedef EllenBinTreeMap< rcu_gpt, Key, Value, traits_EllenBinTreeMap_gpt >EllenBinTreeMap_rcu_gpt;
#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
struct traits_EllenBinTreeMap_shb : traits_EllenBinTreeMap {
typedef cds::memory::pool_allocator< typename ellen_bintree_props::shb::update_desc, ellen_bintree_pool::update_desc_pool_accessor > update_desc_allocator;
};
- typedef cc::EllenBinTreeMap< rcu_shb, Key, Value, traits_EllenBinTreeMap_shb >EllenBinTreeMap_rcu_shb;
+ typedef EllenBinTreeMap< rcu_shb, Key, Value, traits_EllenBinTreeMap_shb >EllenBinTreeMap_rcu_shb;
struct traits_EllenBinTreeMap_sht : traits_EllenBinTreeMap {
typedef cds::memory::pool_allocator< typename ellen_bintree_props::sht::update_desc, ellen_bintree_pool::update_desc_pool_accessor > update_desc_allocator;
};
- typedef cc::EllenBinTreeMap< rcu_sht, Key, Value, traits_EllenBinTreeMap_sht >EllenBinTreeMap_rcu_sht;
+ typedef EllenBinTreeMap< rcu_sht, Key, Value, traits_EllenBinTreeMap_sht >EllenBinTreeMap_rcu_sht;
#endif
struct traits_EllenBinTreeMap_yield : public traits_EllenBinTreeMap
struct traits_EllenBinTreeMap_hp_yield : traits_EllenBinTreeMap_yield {
typedef cds::memory::pool_allocator< typename ellen_bintree_props::hp_gc::update_desc, ellen_bintree_pool::update_desc_pool_accessor > update_desc_allocator;
};
- typedef cc::EllenBinTreeMap< cds::gc::HP, Key, Value, traits_EllenBinTreeMap_hp_yield >EllenBinTreeMap_hp_yield;
+ typedef EllenBinTreeMap< cds::gc::HP, Key, Value, traits_EllenBinTreeMap_hp_yield >EllenBinTreeMap_hp_yield;
struct traits_EllenBinTreeMap_dhp_yield : traits_EllenBinTreeMap_yield {
typedef cds::memory::pool_allocator< typename ellen_bintree_props::dhp_gc::update_desc, ellen_bintree_pool::update_desc_pool_accessor > update_desc_allocator;
};
- typedef cc::EllenBinTreeMap< cds::gc::DHP, Key, Value, traits_EllenBinTreeMap_dhp_yield >EllenBinTreeMap_dhp_yield;
+ typedef EllenBinTreeMap< cds::gc::DHP, Key, Value, traits_EllenBinTreeMap_dhp_yield >EllenBinTreeMap_dhp_yield;
struct traits_EllenBinTreeMap_gpb_yield : traits_EllenBinTreeMap_yield {
typedef cds::memory::pool_allocator< typename ellen_bintree_props::gpb::update_desc, ellen_bintree_pool::update_desc_pool_accessor > update_desc_allocator;
};
- typedef cc::EllenBinTreeMap< rcu_gpb, Key, Value, traits_EllenBinTreeMap_gpb_yield >EllenBinTreeMap_rcu_gpb_yield;
+ typedef EllenBinTreeMap< rcu_gpb, Key, Value, traits_EllenBinTreeMap_gpb_yield >EllenBinTreeMap_rcu_gpb_yield;
struct traits_EllenBinTreeMap_stat: public cc::ellen_bintree::make_set_traits<
{
typedef cds::memory::pool_allocator< typename ellen_bintree_props::hp_gc::update_desc, ellen_bintree_pool::update_desc_pool_accessor > update_desc_allocator;
};
- typedef cc::EllenBinTreeMap< cds::gc::HP, Key, Value, traits_EllenBinTreeMap_stat_hp > EllenBinTreeMap_hp_stat;
+ typedef EllenBinTreeMap< cds::gc::HP, Key, Value, traits_EllenBinTreeMap_stat_hp > EllenBinTreeMap_hp_stat;
struct traits_EllenBinTreeMap_stat_dhp : public traits_EllenBinTreeMap_stat
{
typedef cds::memory::pool_allocator< typename ellen_bintree_props::dhp_gc::update_desc, ellen_bintree_pool::update_desc_pool_accessor > update_desc_allocator;
};
- typedef cc::EllenBinTreeMap< cds::gc::HP, Key, Value, traits_EllenBinTreeMap_stat_dhp > EllenBinTreeMap_dhp_stat;
+ typedef EllenBinTreeMap< cds::gc::HP, Key, Value, traits_EllenBinTreeMap_stat_dhp > EllenBinTreeMap_dhp_stat;
struct traits_EllenBinTreeMap_stat_gpi : public traits_EllenBinTreeMap_stat
{
typedef cds::memory::pool_allocator< typename ellen_bintree_props::gpi::update_desc, ellen_bintree_pool::update_desc_pool_accessor > update_desc_allocator;
};
- typedef cc::EllenBinTreeMap< rcu_gpi, Key, Value, traits_EllenBinTreeMap_stat_gpi > EllenBinTreeMap_rcu_gpi_stat;
+ typedef EllenBinTreeMap< rcu_gpi, Key, Value, traits_EllenBinTreeMap_stat_gpi > EllenBinTreeMap_rcu_gpi_stat;
struct traits_EllenBinTreeMap_stat_gpb : public traits_EllenBinTreeMap_stat
{
typedef cds::memory::pool_allocator< typename ellen_bintree_props::gpb::update_desc, ellen_bintree_pool::update_desc_pool_accessor > update_desc_allocator;
};
- typedef cc::EllenBinTreeMap< rcu_gpb, Key, Value, traits_EllenBinTreeMap_stat_gpb > EllenBinTreeMap_rcu_gpb_stat;
+ typedef EllenBinTreeMap< rcu_gpb, Key, Value, traits_EllenBinTreeMap_stat_gpb > EllenBinTreeMap_rcu_gpb_stat;
struct traits_EllenBinTreeMap_stat_gpt : public traits_EllenBinTreeMap_stat
{
typedef cds::memory::pool_allocator< typename ellen_bintree_props::gpt::update_desc, ellen_bintree_pool::update_desc_pool_accessor > update_desc_allocator;
};
- typedef cc::EllenBinTreeMap< rcu_gpt, Key, Value, traits_EllenBinTreeMap_stat_gpt > EllenBinTreeMap_rcu_gpt_stat;
+ typedef EllenBinTreeMap< rcu_gpt, Key, Value, traits_EllenBinTreeMap_stat_gpt > EllenBinTreeMap_rcu_gpt_stat;
#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
struct traits_EllenBinTreeMap_stat_shb : public traits_EllenBinTreeMap_stat
{
typedef cds::memory::pool_allocator< typename ellen_bintree_props::shb::update_desc, ellen_bintree_pool::update_desc_pool_accessor > update_desc_allocator;
};
- typedef cc::EllenBinTreeMap< rcu_shb, Key, Value, traits_EllenBinTreeMap_stat_shb > EllenBinTreeMap_rcu_shb_stat;
+ typedef EllenBinTreeMap< rcu_shb, Key, Value, traits_EllenBinTreeMap_stat_shb > EllenBinTreeMap_rcu_shb_stat;
struct traits_EllenBinTreeMap_stat_sht : public traits_EllenBinTreeMap_stat
{
typedef cds::memory::pool_allocator< typename ellen_bintree_props::sht::update_desc, ellen_bintree_pool::update_desc_pool_accessor > update_desc_allocator;
};
- typedef cc::EllenBinTreeMap< rcu_sht, Key, Value, traits_EllenBinTreeMap_stat_sht > EllenBinTreeMap_rcu_sht_stat;
+ typedef EllenBinTreeMap< rcu_sht, Key, Value, traits_EllenBinTreeMap_stat_sht > EllenBinTreeMap_rcu_sht_stat;
#endif
};
template <typename GC, typename Key, typename T, typename Traits>
- static inline void print_stat( cc::EllenBinTreeMap<GC, Key, T, Traits> const& s )
+ static inline void print_stat( EllenBinTreeMap<GC, Key, T, Traits> const& s )
{
CPPUNIT_MSG( s.statistics() );
}
template <typename GC, typename Key, typename T, typename Traits>
- static inline void additional_cleanup( cc::EllenBinTreeMap<GC, Key, T, Traits>& /*s*/ )
+ static inline void additional_cleanup( EllenBinTreeMap<GC, Key, T, Traits>& /*s*/ )
{
ellen_bintree_pool::internal_node_counter::reset();
}
}
} // namespace ellen_bintree_check
template <typename GC, typename Key, typename T, typename Traits>
- static inline void additional_check( cc::EllenBinTreeMap<GC, Key, T, Traits>& s )
+ static inline void additional_check( EllenBinTreeMap<GC, Key, T, Traits>& s )
{
GC::force_dispose();
ellen_bintree_check::check_stat( s.statistics() );
}
template <typename GC, typename Key, typename T, typename Traits>
- static inline void check_before_cleanup( cc::EllenBinTreeMap<GC, Key, T, Traits>& m )
+ static inline void check_before_cleanup( EllenBinTreeMap<GC, Key, T, Traits>& m )
{
CPPUNIT_MSG( " Check internal consistency (single-threaded)..." );
CPPUNIT_CHECK_CURRENT( m.check_consistency() );
// for testing
static CDS_CONSTEXPR bool const c_bExtractSupported = true;
- static CDS_CONSTEXPR bool const c_bLoadFactorDepended = true;
+ static CDS_CONSTEXPR bool const c_bLoadFactorDepended = false;
};
struct tag_SkipListMap;