{
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();
}
static_assert( std::is_same<gc, typename bucket_type::gc>::value, "GC and OrderedList::gc must be the same");
// atomicity::empty_item_counter is not allowed as a item counter
- static_assert( !std::is_same<item_counter, atomicity::empty_item_counter>::value,
+ static_assert( !std::is_same<item_counter, atomicity::empty_item_counter>::value,
"atomicity::empty_item_counter is not allowed as a item counter");
m_Buckets = bucket_table_allocator().NewArray( bucket_count() );
synchronization.
*/
template <typename K, typename Func>
- bool insert_key( const K& key, Func func )
+ bool insert_with( const K& key, Func func )
{
- const bool bRet = bucket( key ).insert_key( key, func );
+ const bool bRet = bucket( key ).insert_with( key, func );
if ( bRet )
++m_ItemCounter;
return bRet;
/// Extracts the item with specified \p key
/** \anchor cds_nonintrusive_MichaelHashMap_hp_extract
The function searches an item with key equal to \p key,
- unlinks it from the set, and returns it in \p dest parameter.
- If the item with key equal to \p key is not found the function returns \p false.
+ unlinks it from the set, and returns it as \p guarded_ptr.
+ If \p key is not found the function returns an empty guarded pointer.
Note the compare functor should accept a parameter of type \p K that may be not the same as \p key_type.
- The extracted item is freed automatically when returned \ref guarded_ptr object will be destroyed or released.
+ The extracted item is freed automatically when returned \p guarded_ptr object will be destroyed or released.
@note Each \p guarded_ptr object uses the GC's guard that can be limited resource.
Usage:
michael_map theMap;
// ...
{
- michael_map::guarded_ptr gp;
- theMap.extract( gp, 5 );
- // Deal with gp
- // ...
-
+ michael_map::guarded_ptr gp( theMap.extract( 5 ));
+ if ( gp ) {
+ // Deal with gp
+ // ...
+ }
// Destructor of gp releases internal HP guard
}
\endcode
*/
template <typename K>
- bool extract( guarded_ptr& dest, K const& key )
+ guarded_ptr extract( K const& key )
{
- const bool bRet = bucket( key ).extract( dest, key );
- if ( bRet )
+ guarded_ptr gp( bucket( key ).extract( key ));
+ if ( gp )
--m_ItemCounter;
- return bRet;
+ return gp;
}
/// Extracts the item using compare functor \p pred
/**
- The function is an analog of \ref cds_nonintrusive_MichaelHashMap_hp_extract "extract(guarded_ptr&, K const&)"
+ The function is an analog of \ref cds_nonintrusive_MichaelHashMap_hp_extract "extract(K const&)"
but \p pred predicate is used for key comparing.
- \p Less functor has the semantics like \p std::less but should take arguments of type \ref key_type and \p K
+ \p Less functor has the semantics like \p std::less but should take arguments of type \p key_type and \p K
in any order.
\p pred must imply the same element order as the comparator used for building the map.
*/
template <typename K, typename Less>
- bool extract_with( guarded_ptr& dest, K const& key, Less pred )
+ guarded_ptr extract_with( K const& key, Less pred )
{
- const bool bRet = bucket( key ).extract_with( dest, key, pred );
- if ( bRet )
+ guarded_ptr gp( bucket( key ).extract_with( key, pred ));
+ if ( gp )
--m_ItemCounter;
- return bRet;
+ return gp;
}
/// Finds the key \p key
/// Finds \p key and return the item found
/** \anchor cds_nonintrusive_MichaelHashMap_hp_get
The function searches the item with key equal to \p key
- and assigns the item found to guarded pointer \p ptr.
- The function returns \p true if \p key is found, and \p false otherwise.
- If \p key is not found the \p ptr parameter is not changed.
+ and returns the guarded pointer to the item found.
+ If \p key is not found the function returns an empty guarded pointer,
@note Each \p guarded_ptr object uses one GC's guard which can be limited resource.
michael_map theMap;
// ...
{
- michael_map::guarded_ptr gp;
- if ( theMap.get( gp, 5 )) {
+ michael_map::guarded_ptr gp( theMap.get( 5 ));
+ if ( gp ) {
// Deal with gp
//...
}
should accept a parameter of type \p K that can be not the same as \p key_type.
*/
template <typename K>
- bool get( guarded_ptr& ptr, K const& key )
+ guarded_ptr get( K const& key )
{
- return bucket( key ).get( ptr, key );
+ return bucket( key ).get( key );
}
/// Finds \p key and return the item found
/**
- The function is an analog of \ref cds_nonintrusive_MichaelHashMap_hp_get "get( guarded_ptr& ptr, K const&)"
+ The function is an analog of \ref cds_nonintrusive_MichaelHashMap_hp_get "get( K const&)"
but \p pred is used for comparing the keys.
- \p Less functor has the semantics like \p std::less but should take arguments of type \ref key_type and \p K
+ \p Less functor has the semantics like \p std::less but should take arguments of type \p key_type and \p K
in any order.
\p pred must imply the same element order as the comparator used for building the map.
*/
template <typename K, typename Less>
- bool get_with( guarded_ptr& ptr, K const& key, Less pred )
+ guarded_ptr get_with( K const& key, Less pred )
{
- return bucket( key ).get_with( ptr, key, pred );
+ return bucket( key ).get_with( key, pred );
}
/// Clears the map (not atomic)