//$$CDS-header$$
-#ifndef __CDS_CONTAINER_MICHAEL_SET_RCU_H
-#define __CDS_CONTAINER_MICHAEL_SET_RCU_H
+#ifndef CDSLIB_CONTAINER_MICHAEL_SET_RCU_H
+#define CDSLIB_CONTAINER_MICHAEL_SET_RCU_H
#include <cds/container/details/michael_set_base.h>
#include <cds/details/allocator.h>
Template parameters are:
- \p RCU - one of \ref cds_urcu_gc "RCU type"
- - \p OrderedList - ordered list implementation used as the bucket for hash set, for example,
+ - \p OrderedList - ordered list implementation used as the bucket for hash set, for example,
\ref cds_nonintrusive_MichaelList_rcu "MichaelList".
The ordered list implementation specifies the type \p T stored in the hash-set,
the comparison functor for the type \p T and other features specific for
{
return get_const_begin();
}
- const_iterator cbegin()
+ const_iterator cbegin() const
{
return get_const_begin();
}
{
return get_const_end();
}
- const_iterator cend()
+ const_iterator cend() const
{
return get_const_end();
}
/// Extracts an item from the set
/** \anchor cds_nonintrusive_MichaelHashSet_rcu_extract
The function searches an item with key equal to \p key in the set,
- unlinks it from the set, places item pointer into \p dest argument, and returns \p true.
- If the item with the key equal to \p key is not found the function return \p false.
+ unlinks it from the set, and returns \ref cds::urcu::exempt_ptr "exempt_ptr" pointer to the item found.
+ If the item with the key equal to \p key is not found the function return an empty \p exempt_ptr.
@note The function does NOT call RCU read-side lock or synchronization,
and does NOT dispose the item found. It just excludes the item from the set
// Now, you can apply extract function
// Note that you must not delete the item found inside the RCU lock
- if ( theSet.extract( p, 10 )) {
+ p = theSet.extract( 10 );
+ if ( p ) {
// do something with p
...
}
\endcode
*/
template <typename Q>
- bool extract( exempt_ptr& dest, Q const& key )
+ exempt_ptr extract( Q const& key )
{
- if ( bucket( key ).extract( dest, key )) {
+ exempt_ptr p = bucket( key ).extract( key );
+ if ( p )
--m_ItemCounter;
- return true;
- }
- return false;
+ return p;
}
/// Extracts an item from the set using \p pred predicate for searching
/**
- The function is an analog of \ref cds_nonintrusive_MichaelHashSet_rcu_extract "extract(exempt_ptr&, Q const&)"
- but \p pred is used for key comparing.
+ The function is an analog of \p extract(Q const&) but \p pred is used for key comparing.
\p Less functor has the interface like \p std::less.
\p pred must imply the same element order as the comparator used for building the set.
*/
template <typename Q, typename Less>
- bool extract_with( exempt_ptr& dest, Q const& key, Less pred )
+ exempt_ptr extract_with( Q const& key, Less pred )
{
- if ( bucket( key ).extract_with( dest, key, pred )) {
+ exempt_ptr p = bucket( key ).extract_with( key, pred );
+ if ( p )
--m_ItemCounter;
- return true;
- }
- return false;
+ return p;
}
/// Finds the key \p key
{
return bucket( key ).find( key, f );
}
+ //@cond
+ template <typename Q, typename Func>
+ bool find( Q const& key, Func f ) const
+ {
+ return bucket( key ).find( key, f );
+ }
+ //@endcond
/// Finds the key \p key using \p pred predicate for searching
/**
{
return bucket( key ).find_with( key, pred, f );
}
+ //@cond
+ template <typename Q, typename Less, typename Func>
+ bool find_with( Q const& key, Less pred, Func f ) const
+ {
+ return bucket( key ).find_with( key, pred, f );
+ }
+ //@endcond
/// Finds the key \p key
/** \anchor cds_nonintrusive_MichealSet_rcu_find_val
}} // namespace cds::container
-#endif // ifndef __CDS_CONTAINER_MICHAEL_SET_RCU_H
+#endif // ifndef CDSLIB_CONTAINER_MICHAEL_SET_RCU_H