/// Delete \p key from the map
/**
\p key_type must be constructible from value of type \p K.
- The function deeltes the element with hash value equal to <tt>hash( key_type( key ))</tt>
+ The function deletes the element with hash value equal to <tt>hash( key_type( key ))</tt>
Return \p true if \p key is found and deleted, \p false otherwise.
/// Delete \p key from the map
/**
\p key_type must be constructible from value of type \p K.
- The function deeltes the element with hash value equal to <tt>hash( key_type( key ))</tt>
+ The function deletes the element with hash value equal to <tt>hash( key_type( key ))</tt>
Return \p true if \p key is found and deleted, \p false otherwise.
*/
bool insert( K const& key )
{
//TODO: pass arguments by reference (make_pair makes copy)
- return base_class::insert( std::make_pair( key, mapped_type() ) );
+ return base_class::insert( std::make_pair( key, mapped_type()));
}
/// Inserts new node
bool insert( K const& key, V const& val )
{
//TODO: pass arguments by reference (make_pair makes copy)
- return base_class::insert( std::make_pair(key, val) );
+ return base_class::insert( std::make_pair(key, val));
}
/// Inserts new node and initialize it by a functor
bool insert_with( K const& key, Func func )
{
//TODO: pass arguments by reference (make_pair makes copy)
- return base_class::insert( std::make_pair( key, mapped_type() ), func );
+ return base_class::insert( std::make_pair( key, mapped_type()), func );
}
/// For key \p key inserts data of type \p mapped_type created from \p args
std::pair<bool, bool> update( K const& key, Func func, bool bAllowInsert = true )
{
//TODO: pass arguments by reference (make_pair makes copy)
- return base_class::update( std::make_pair( key, mapped_type() ),
+ return base_class::update( std::make_pair( key, mapped_type()),
[&func](bool bNew, value_type& item, value_type const& /*val*/) {
func( bNew, item );
},
bool erase_with( K const& key, Less pred )
{
CDS_UNUSED( pred );
- return base_class::erase_with( key, cds::details::predicate_wrapper<value_type, Less, key_accessor>() );
+ return base_class::erase_with( key, cds::details::predicate_wrapper<value_type, Less, key_accessor>());
}
/// Deletes \p key from the map
{
CDS_UNUSED( pred );
guarded_ptr gp;
- base_class::extract_with_( gp.guard(), key, cds::details::predicate_wrapper<value_type, Less, key_accessor>() );
+ base_class::extract_with_( gp.guard(), key, cds::details::predicate_wrapper<value_type, Less, key_accessor>());
return gp;
}
bool contains( K const& key, Less pred )
{
CDS_UNUSED( pred );
- return base_class::contains( key, cds::details::predicate_wrapper<value_type, Less, key_accessor>() );
+ return base_class::contains( key, cds::details::predicate_wrapper<value_type, Less, key_accessor>());
}
//@cond
template <typename K, typename Less>
{
CDS_UNUSED( pred );
guarded_ptr gp;
- base_class::get_with_( gp.guard(), key, cds::details::predicate_wrapper<value_type, Less, key_accessor>() );
+ base_class::get_with_( gp.guard(), key, cds::details::predicate_wrapper<value_type, Less, key_accessor>());
return gp;
}
assert( pNode != nullptr );
scoped_node_ptr p(pNode);
- if ( base_class::insert( *pNode ) ) {
+ if ( base_class::insert( *pNode )) {
p.release();
return true;
}
*/
iterator begin()
{
- return iterator( base_class::begin() );
+ return iterator( base_class::begin());
}
/// Returns an iterator that addresses the location succeeding the last element in a set
*/
iterator end()
{
- return iterator( base_class::end() );
+ return iterator( base_class::end());
}
/// Returns a forward const iterator addressing the first element in a set
/// Returns a forward const iterator addressing the first element in a set
const_iterator cbegin() const
{
- return const_iterator( base_class::cbegin() );
+ return const_iterator( base_class::cbegin());
}
/// Returns an const iterator that addresses the location succeeding the last element in a set
/// Returns an const iterator that addresses the location succeeding the last element in a set
const_iterator cend() const
{
- return const_iterator( base_class::cend() );
+ return const_iterator( base_class::cend());
}
public:
template <typename Q>
bool insert( Q const& val )
{
- return insert_node( alloc_node( val ) );
+ return insert_node( alloc_node( val ));
}
/// Inserts new node
bool erase_with( Q const& key, Less pred )
{
CDS_UNUSED( pred );
- return base_class::erase_with( key, typename maker::template predicate_wrapper<Less>::type() );
+ return base_class::erase_with( key, typename maker::template predicate_wrapper<Less>::type());
}
/// Deletes \p key from the set
bool contains( Q const& key, Less pred )
{
CDS_UNUSED( pred );
- return base_class::contains( key, typename maker::template predicate_wrapper<Less>::type() );
+ return base_class::contains( key, typename maker::template predicate_wrapper<Less>::type());
}
//@cond
template <typename Q, typename Less>
bool extract_with_( typename guarded_ptr::native_guard& guard, Q const& key, Less pred )
{
CDS_UNUSED( pred );
- return base_class::extract_with_( guard, key, typename maker::template predicate_wrapper<Less>::type() );
+ return base_class::extract_with_( guard, key, typename maker::template predicate_wrapper<Less>::type());
}
template <typename Q, typename Less>
bool get_with_( typename guarded_ptr::native_guard& guard, Q const& key, Less pred )
{
CDS_UNUSED( pred );
- return base_class::get_with_( guard, key, typename maker::template predicate_wrapper<Less>::type() );
+ return base_class::get_with_( guard, key, typename maker::template predicate_wrapper<Less>::type());
}
//@endcond
>
class FeldmanHashSet< cds::urcu::gc< RCU >, T, Traits >: protected feldman_hashset::multilevel_array<T, Traits>
{
+ //@cond
typedef feldman_hashset::multilevel_array<T, Traits> base_class;
+ //@endcond
+
public:
typedef cds::urcu::gc< RCU > gc; ///< RCU garbage collector
typedef T value_type; ///< type of value stored in the set
*/
void clear()
{
- clear_array( head(), head_size() );
+ clear_array( head(), head_size());
}
/// Checks if the set is empty
rcu_lock rcuLock;
if ( pos.pArr->nodes[pos.nSlot].load(memory_model::memory_order_acquire) == slot) {
- if ( slot.ptr() ) {
+ if ( slot.ptr()) {
if ( cmp( hash, hash_accessor()(*slot.ptr())) == 0 ) {
// the item with that hash value already exists
// Replace it with val
assert( slot.bits() == 0 );
if ( pos.pArr->nodes[pos.nSlot].load( memory_model::memory_order_acquire ) == slot ) {
- if ( slot.ptr() ) {
- if ( cmp( hash, hash_accessor()(*slot.ptr()) ) == 0 && pred( *slot.ptr() ) ) {
+ if ( slot.ptr()) {
+ if ( cmp( hash, hash_accessor()(*slot.ptr())) == 0 && pred( *slot.ptr())) {
// item found - replace it with nullptr
- if ( pos.pArr->nodes[pos.nSlot].compare_exchange_strong( slot, node_ptr( nullptr ), memory_model::memory_order_acquire, atomics::memory_order_relaxed ) ) {
+ if ( pos.pArr->nodes[pos.nSlot].compare_exchange_strong( slot, node_ptr( nullptr ), memory_model::memory_order_acquire, atomics::memory_order_relaxed )) {
--m_ItemCounter;
stats().onEraseSuccess();
value_type * search(hash_type const& hash )
{
- assert( gc::is_locked() );
+ assert( gc::is_locked());
traverse_data pos( hash, *this );
hash_comparator cmp;
// slot value has been changed - retry
stats().onSlotChanged();
}
- else if ( slot.ptr() && cmp( hash, hash_accessor()(*slot.ptr()) ) == 0 ) {
+ else if ( slot.ptr() && cmp( hash, hash_accessor()(*slot.ptr())) == 0 ) {
// item found
stats().onFindSuccess();
return slot.ptr();
>
class FeldmanHashSet: protected feldman_hashset::multilevel_array<T, Traits>
{
+ //@cond
typedef feldman_hashset::multilevel_array<T, Traits> base_class;
+ //@endcond
public:
typedef GC gc; ///< Garbage collector
if ( slot.bits() == base_class::flag_array_node ) {
// array node, go down the tree
assert( slot.ptr() != nullptr );
- pNode = to_array( slot.ptr() );
+ pNode = to_array( slot.ptr());
idx = 0;
nodeSize = arrayNodeSize;
}
}
else {
// end()
- assert( pNode == m_set->head() );
+ assert( pNode == m_set->head());
assert( idx == headSize );
m_pNode = pNode;
m_idx = idx;
if ( slot.bits() == base_class::flag_array_node ) {
// array node, go down the tree
assert( slot.ptr() != nullptr );
- pNode = to_array( slot.ptr() );
+ pNode = to_array( slot.ptr());
nodeSize = arrayNodeSize;
idx = nodeSize - 1;
}
}
else {
// rend()
- assert( pNode == m_set->head() );
+ assert( pNode == m_set->head());
assert( idx == endIdx );
m_pNode = pNode;
m_idx = idx;
template <class Iterator>
Iterator init_rbegin() const
{
- return Iterator( *this, head(), head_size() );
+ return Iterator( *this, head(), head_size());
}
template <class Iterator>
*/
void clear()
{
- clear_array( head(), head_size() );
+ clear_array( head(), head_size());
}
/// Checks if the set is empty
/// Returns a reverse iterator to the first element of the reversed set
reverse_iterator rbegin()
{
- return reverse_iterator( *this, head(), head_size() );
+ return reverse_iterator( *this, head(), head_size());
}
/// Returns a const reverse iterator to the first element of the reversed set
const_reverse_iterator rbegin() const
{
- return const_reverse_iterator( *this, head(), head_size() );
+ return const_reverse_iterator( *this, head(), head_size());
}
/// Returns a const reverse iterator to the first element of the reversed set
const_reverse_iterator crbegin()
{
- return const_reverse_iterator( *this, head(), head_size() );
+ return const_reverse_iterator( *this, head(), head_size());
}
/// Returns a reverse iterator to the element following the last element of the reversed set
if ( slot.bits() == base_class::flag_array_node ) {
// array node, go down the tree
assert( slot.ptr() != nullptr );
- clear_array( to_array( slot.ptr()), array_node_size() );
+ clear_array( to_array( slot.ptr()), array_node_size());
break;
}
else if ( slot.bits() == base_class::flag_array_converting ) {
assert( slot.ptr() != nullptr );
assert( slot.bits() == base_class::flag_array_node );
- clear_array( to_array( slot.ptr()), array_node_size() );
+ clear_array( to_array( slot.ptr()), array_node_size());
break;
}
else {
// data node
if ( pArr->compare_exchange_strong( slot, node_ptr(), memory_model::memory_order_acquire, atomics::memory_order_relaxed )) {
- if ( slot.ptr() ) {
- gc::template retire<disposer>( slot.ptr() );
+ if ( slot.ptr()) {
+ gc::template retire<disposer>( slot.ptr());
--m_ItemCounter;
stats().onEraseSuccess();
}
return false;
if ( iter.m_pNode == head() && iter.m_idx >= head_size())
return false;
- if ( iter.m_idx >= array_node_size() )
+ if ( iter.m_idx >= array_node_size())
return false;
for (;;) {
node_ptr slot = iter.m_pNode->nodes[iter.m_idx].load( memory_model::memory_order_acquire );
- if ( slot.bits() == 0 && slot.ptr() == iter.pointer() ) {
- if ( iter.m_pNode->nodes[iter.m_idx].compare_exchange_strong(slot, node_ptr(nullptr), memory_model::memory_order_acquire, atomics::memory_order_relaxed) ) {
+ if ( slot.bits() == 0 && slot.ptr() == iter.pointer()) {
+ if ( iter.m_pNode->nodes[iter.m_idx].compare_exchange_strong(slot, node_ptr(nullptr), memory_model::memory_order_acquire, atomics::memory_order_relaxed)) {
// the item is guarded by iterator, so we may retire it safely
- gc::template retire<disposer>( slot.ptr() );
+ gc::template retire<disposer>( slot.ptr());
--m_ItemCounter;
stats().onEraseSuccess();
return true;
struct clean_disposer {
void operator()( value_type * p )
{
- michael_list::node_cleaner<gc, node_type, memory_model>()( node_traits::to_node_ptr( p ) );
+ michael_list::node_cleaner<gc, node_type, memory_model>()( node_traits::to_node_ptr( p ));
disposer()( p );
}
};
static void retire_node( node_type * pNode )
{
assert( pNode != nullptr );
- gc::template retire<clean_disposer>( node_traits::to_value_ptr( *pNode ) );
+ gc::template retire<clean_disposer>( node_traits::to_value_ptr( *pNode ));
}
static bool link_node( node_type * pNode, position& pos )
marked_node_ptr pNext;
do {
pNext = pCur->m_pNext.load(memory_model::memory_order_relaxed);
- g.assign( node_traits::to_value_ptr( pNext.ptr() ));
- } while ( pNext != pCur->m_pNext.load(memory_model::memory_order_acquire) );
+ g.assign( node_traits::to_value_ptr( pNext.ptr()));
+ } while ( pNext != pCur->m_pNext.load(memory_model::memory_order_acquire));
- if ( pNext.ptr() ) {
- m_pNode = m_Guard.assign( g.template get<value_type>() );
- }
+ if ( pNext.ptr())
+ m_pNode = m_Guard.assign( g.template get<value_type>());
else {
m_pNode = nullptr;
m_Guard.clear();
{
for (;;) {
marked_node_ptr p = pNode.load(memory_model::memory_order_relaxed);
- if ( p.ptr() ) {
- m_pNode = m_Guard.assign( node_traits::to_value_ptr( p.ptr() ) );
+ if ( p.ptr()) {
+ m_pNode = m_Guard.assign( node_traits::to_value_ptr( p.ptr()));
}
else {
m_pNode = nullptr;
m_Guard.clear();
}
- if ( p == pNode.load(memory_model::memory_order_acquire) )
+ if ( p == pNode.load(memory_model::memory_order_acquire))
break;
}
}
template <typename Q>
bool erase( Q const& key )
{
- return erase_at( m_pHead, key, key_comparator() );
+ return erase_at( m_pHead, key, key_comparator());
}
/// Deletes the item from the list using \p pred predicate for searching
guarded_ptr extract( Q const& key )
{
guarded_ptr gp;
- extract_at( m_pHead, gp.guard(), key, key_comparator() );
+ extract_at( m_pHead, gp.guard(), key, key_comparator());
return gp;
}
{
CDS_UNUSED( pred );
guarded_ptr gp;
- extract_at( m_pHead, gp.guard(), key, cds::opt::details::make_comparator_from_less<Less>() );
+ extract_at( m_pHead, gp.guard(), key, cds::opt::details::make_comparator_from_less<Less>());
return gp;
}
template <typename Q>
bool contains( Q const& key )
{
- return find_at( m_pHead, key, key_comparator() );
+ return find_at( m_pHead, key, key_comparator());
}
//@cond
template <typename Q>
bool contains( Q const& key, Less pred )
{
CDS_UNUSED( pred );
- return find_at( m_pHead, key, cds::opt::details::make_comparator_from_less<Less>() );
+ return find_at( m_pHead, key, cds::opt::details::make_comparator_from_less<Less>());
}
//@cond
template <typename Q, typename Less>
guarded_ptr get( Q const& key )
{
guarded_ptr gp;
- get_at( m_pHead, gp.guard(), key, key_comparator() );
+ get_at( m_pHead, gp.guard(), key, key_comparator());
return gp;
}
{
CDS_UNUSED( pred );
guarded_ptr gp;
- get_at( m_pHead, gp.guard(), key, cds::opt::details::make_comparator_from_less<Less>() );
+ get_at( m_pHead, gp.guard(), key, cds::opt::details::make_comparator_from_less<Less>());
return gp;
}
marked_node_ptr head;
while ( true ) {
head = m_pHead.load(memory_model::memory_order_relaxed);
- if ( head.ptr() )
- guard.assign( node_traits::to_value_ptr( *head.ptr() ));
+ if ( head.ptr())
+ guard.assign( node_traits::to_value_ptr( *head.ptr()));
if ( m_pHead.load(memory_model::memory_order_acquire) == head ) {
if ( head.ptr() == nullptr )
break;
- value_type& val = *node_traits::to_value_ptr( *head.ptr() );
+ value_type& val = *node_traits::to_value_ptr( *head.ptr());
unlink( val );
}
}
// Hack: convert node_type to value_type.
// In principle, auxiliary node can be non-reducible to value_type
// We assume that comparator can correctly distinguish aux and regular node.
- return insert_at( refHead, *node_traits::to_value_ptr( pNode ) );
+ return insert_at( refHead, *node_traits::to_value_ptr( pNode ));
}
bool insert_at( atomic_node_ptr& refHead, value_type& val )
position pos;
while ( true ) {
- if ( search( refHead, val, pos, key_comparator() ) )
+ if ( search( refHead, val, pos, key_comparator()))
return false;
- if ( link_node( pNode, pos ) ) {
+ if ( link_node( pNode, pos )) {
++m_ItemCounter;
return true;
}
position pos;
while ( true ) {
- if ( search( refHead, val, pos, key_comparator() ) )
+ if ( search( refHead, val, pos, key_comparator()))
return false;
typename gc::Guard guard;
guard.assign( &val );
- if ( link_node( pNode, pos ) ) {
+ if ( link_node( pNode, pos )) {
f( val );
++m_ItemCounter;
return true;
node_type * pNode = node_traits::to_node_ptr( val );
while ( true ) {
- if ( search( refHead, val, pos, key_comparator() ) ) {
- if ( pos.pCur->m_pNext.load(memory_model::memory_order_acquire).bits() ) {
+ if ( search( refHead, val, pos, key_comparator())) {
+ if ( pos.pCur->m_pNext.load(memory_model::memory_order_acquire).bits()) {
back_off()();
- continue ; // the node found is marked as deleted
+ continue; // the node found is marked as deleted
}
- assert( key_comparator()( val, *node_traits::to_value_ptr( *pos.pCur ) ) == 0 );
+ assert( key_comparator()( val, *node_traits::to_value_ptr( *pos.pCur )) == 0 );
func( false, *node_traits::to_value_ptr( *pos.pCur ) , val );
return std::make_pair( true, false );
typename gc::Guard guard;
guard.assign( &val );
- if ( link_node( pNode, pos ) ) {
+ if ( link_node( pNode, pos )) {
++m_ItemCounter;
func( true, val, val );
return std::make_pair( true, true );
position pos;
back_off bkoff;
- while ( search( refHead, val, pos, key_comparator() ) ) {
+ while ( search( refHead, val, pos, key_comparator())) {
if ( node_traits::to_value_ptr( *pos.pCur ) == &val ) {
- if ( unlink_node( pos ) ) {
+ if ( unlink_node( pos )) {
--m_ItemCounter;
return true;
}
{
back_off bkoff;
while ( search( refHead, val, pos, cmp )) {
- if ( unlink_node( pos ) ) {
- f( *node_traits::to_value_ptr( *pos.pCur ) );
+ if ( unlink_node( pos )) {
+ f( *node_traits::to_value_ptr( *pos.pCur ));
--m_ItemCounter;
return true;
}
position pos;
back_off bkoff;
while ( search( refHead, val, pos, cmp )) {
- if ( unlink_node( pos ) ) {
- dest.set( pos.guards.template get<value_type>( position::guard_current_item ) );
+ if ( unlink_node( pos )) {
+ dest.set( pos.guards.template get<value_type>( position::guard_current_item ));
--m_ItemCounter;
return true;
}
pCur = pos.guards.protect( position::guard_current_item, *pPrev,
[](marked_node_ptr p) -> value_type *
{
- return node_traits::to_value_ptr( p.ptr() );
+ return node_traits::to_value_ptr( p.ptr());
});
while ( true ) {
pNext = pos.guards.protect( position::guard_next_item, pCur->m_pNext,
[](marked_node_ptr p ) -> value_type *
{
- return node_traits::to_value_ptr( p.ptr() );
+ return node_traits::to_value_ptr( p.ptr());
});
- if ( pPrev->load(memory_model::memory_order_acquire).all() != pCur.ptr() ) {
+ if ( pPrev->load(memory_model::memory_order_acquire).all() != pCur.ptr()) {
bkoff();
goto try_again;
}
if ( pNext.bits() == 1 ) {
// pCur marked i.e. logically deleted. Help the erase/unlink function to unlink pCur node
marked_node_ptr cur( pCur.ptr());
- if ( pPrev->compare_exchange_strong( cur, marked_node_ptr( pNext.ptr() ), memory_model::memory_order_acquire, atomics::memory_order_relaxed )) {
- retire_node( pCur.ptr() );
+ if ( pPrev->compare_exchange_strong( cur, marked_node_ptr( pNext.ptr()), memory_model::memory_order_acquire, atomics::memory_order_relaxed )) {
+ retire_node( pCur.ptr());
}
else {
bkoff();
}
else {
assert( pCur.ptr() != nullptr );
- int nCmp = cmp( *node_traits::to_value_ptr( pCur.ptr() ), val );
+ int nCmp = cmp( *node_traits::to_value_ptr( pCur.ptr()), val );
if ( nCmp >= 0 ) {
pos.pPrev = pPrev;
pos.pCur = pCur.ptr();
static size_t parent_bucket( size_t nBucket )
{
assert( nBucket > 0 );
- return nBucket & ~( 1 << bitop::MSBnz( nBucket ) );
+ return nBucket & ~( 1 << bitop::MSBnz( nBucket ));
}
dummy_node_type * init_bucket( size_t nBucket )
// Allocate a dummy node for new bucket
{
- dummy_node_type * pBucket = alloc_dummy_node( split_list::dummy_hash( nBucket ) );
- if ( m_List.insert_aux_node( pParentBucket, pBucket ) ) {
+ dummy_node_type * pBucket = alloc_dummy_node( split_list::dummy_hash( nBucket ));
+ if ( m_List.insert_aux_node( pParentBucket, pBucket )) {
m_Buckets.bucket( nBucket, pBucket );
m_Stat.onNewBucket();
return pBucket;
if ( pHead == nullptr )
pHead = init_bucket( nBucket );
- assert( pHead->is_dummy() );
+ assert( pHead->is_dummy());
return pHead;
}
size_t sz = m_nBucketCountLog2.load(memory_model::memory_order_relaxed);
const size_t nBucketCount = static_cast<size_t>(1) << sz;
- if ( nBucketCount < m_Buckets.capacity() ) {
+ if ( nBucketCount < m_Buckets.capacity()) {
// we may grow the bucket table
const size_t nLoadFactor = m_Buckets.load_factor();
if ( nMaxCount < max_item_count( nBucketCount, nLoadFactor ))
dummy_node_type * pHead = get_bucket( nHash );
assert( pHead != nullptr );
- if ( m_List.erase_at( pHead, sv, cmp ) ) {
+ if ( m_List.erase_at( pHead, sv, cmp )) {
--m_ItemCounter;
m_Stat.onEraseSuccess();
return true;
dummy_node_type * pHead = get_bucket( nHash );
assert( pHead != nullptr );
- if ( m_List.extract_at( pHead, guard, sv, cmp ) ) {
+ if ( m_List.extract_at( pHead, guard, sv, cmp )) {
--m_ItemCounter;
m_Stat.onExtractSuccess();
return true;
template <typename Q, typename Less>
bool extract_with_( typename guarded_ptr::native_guard& guard, Q const& key, Less )
{
- return extract_( guard, key, typename wrapped_ordered_list::template make_compare_from_less<Less>() );
+ return extract_( guard, key, typename wrapped_ordered_list::template make_compare_from_less<Less>());
}
//@endcond
*/
SplitListSet()
: m_nBucketCountLog2(1)
- , m_nMaxItemCount( max_item_count(2, m_Buckets.load_factor()) )
+ , m_nMaxItemCount( max_item_count(2, m_Buckets.load_factor()))
{
init();
}
)
: m_Buckets( nItemCount, nLoadFactor )
, m_nBucketCountLog2(1)
- , m_nMaxItemCount( max_item_count(2, m_Buckets.load_factor()) )
+ , m_nMaxItemCount( max_item_count(2, m_Buckets.load_factor()))
{
init();
}
dummy_node_type * pHead = get_bucket( nHash );
assert( pHead != nullptr );
- if ( m_List.unlink_at( pHead, val ) ) {
+ if ( m_List.unlink_at( pHead, val )) {
--m_ItemCounter;
m_Stat.onEraseSuccess();
return true;
template <typename Q>
bool erase( Q const& key )
{
- return erase_( key, key_comparator() );
+ return erase_( key, key_comparator());
}
/// Deletes the item from the set with comparing functor \p pred
bool erase_with( const Q& key, Less pred )
{
CDS_UNUSED( pred );
- return erase_( key, typename wrapped_ordered_list::template make_compare_from_less<Less>() );
+ return erase_( key, typename wrapped_ordered_list::template make_compare_from_less<Less>());
}
/// Deletes the item from the set
template <typename Q>
bool contains( Q const& key )
{
- return find_( key, key_comparator() );
+ return find_( key, key_comparator());
}
//@cond
template <typename Q>
bool contains( Q const& key, Less pred )
{
CDS_UNUSED( pred );
- return find_( key, typename wrapped_ordered_list::template make_compare_from_less<Less>() );
+ return find_( key, typename wrapped_ordered_list::template make_compare_from_less<Less>());
}
//@cond
template <typename Q, typename Less>
void clear()
{
iterator it = begin();
- while ( it != end() ) {
+ while ( it != end()) {
iterator i(it);
++i;
unlink( *it );
*/
iterator begin()
{
- return iterator( m_List.begin(), m_List.end() );
+ return iterator( m_List.begin(), m_List.end());
}
/// Returns an iterator that addresses the location succeeding the last element in a split-list
*/
iterator end()
{
- return iterator( m_List.end(), m_List.end() );
+ return iterator( m_List.end(), m_List.end());
}
/// Returns a forward const iterator addressing the first element in a split-list
/// Returns a forward const iterator addressing the first element in a split-list
const_iterator cbegin() const
{
- return const_iterator( m_List.cbegin(), m_List.cend() );
+ return const_iterator( m_List.cbegin(), m_List.cend());
}
/// Returns an const iterator that addresses the location succeeding the last element in a split-list
/// Returns an const iterator that addresses the location succeeding the last element in a split-list
const_iterator cend() const
{
- return const_iterator( m_List.cend(), m_List.cend() );
+ return const_iterator( m_List.cend(), m_List.cend());
}
};
m_arrInsert[i] = i;
m_arrRemove[i] = i;
}
- shuffle( m_arrInsert.begin(), m_arrInsert.end() );
- shuffle( m_arrRemove.begin(), m_arrRemove.end() );
+ shuffle( m_arrInsert.begin(), m_arrInsert.end());
+ shuffle( m_arrRemove.begin(), m_arrRemove.end());
}
void Map_DelOdd::endTestCase()
}
}
else {
- if ( eraser<Map, Map::c_bEraseExactKey>::erase(rMap, arrData[i], 0) )
+ if ( eraser<Map, Map::c_bEraseExactKey>::erase(rMap, arrData[i], 0))
++m_nDeleteSuccess;
else
++m_nDeleteFailed;
pool.add( new insert_thread( pool, testMap ), c_nInsThreadCount );
pool.add( new delete_thread( pool, testMap ), c_nDelThreadCount ? c_nDelThreadCount : cds::OS::topology::processor_count());
pool.run();
- CPPUNIT_MSG( " Duration=" << pool.avgDuration() );
+ CPPUNIT_MSG( " Duration=" << pool.avgDuration());
size_t nInsertSuccess = 0;
size_t nInsertFailed = 0;
if ( c_nExtractThreadCount )
pool.add( new extract_thread( pool, testMap ), c_nExtractThreadCount );
pool.run();
- CPPUNIT_MSG( " Duration=" << pool.avgDuration() );
+ CPPUNIT_MSG( " Duration=" << pool.avgDuration());
size_t nInsertSuccess = 0;
size_t nInsertFailed = 0;
CPPUNIT_MSG( " Check even keys..." );
for ( size_t n = 0; n < c_nMapSize; n +=2 ) {
for ( size_t i = 0; i < c_nInsThreadCount; ++i ) {
- if ( !testMap.contains( key_type(n, i) ) ) {
+ if ( !testMap.contains( key_type(n, i))) {
if ( ++nErrorCount < 10 ) {
CPPUNIT_MSG( "key " << n << "-" << i << " is not found!");
}
CPPUNIT_MSG( " Clear map (single-threaded)..." );
timer.reset();
testMap.clear();
- CPPUNIT_MSG( " Duration=" << timer.duration() );
- CPPUNIT_CHECK_EX( testMap.empty(), ((long long) testMap.size()) );
+ CPPUNIT_MSG( " Duration=" << timer.duration());
+ CPPUNIT_CHECK_EX( testMap.empty(), ((long long) testMap.size()));
additional_check( testMap );
print_stat( testMap );
, nData(0)
, nUpdateCall(0)
, bInitialized( false )
- , threadId( cds::OS::get_current_thread_id() )
+ , threadId( cds::OS::get_current_thread_id())
{}
value_type( value_type const& s )
: nKey(s.nKey)
, nData(s.nData)
, nUpdateCall(s.nUpdateCall.load(atomics::memory_order_relaxed))
- , bInitialized( s.bInitialized.load(atomics::memory_order_relaxed) )
- , threadId( cds::OS::get_current_thread_id() )
+ , bInitialized( s.bInitialized.load(atomics::memory_order_relaxed))
+ , threadId( cds::OS::get_current_thread_id())
{}
// boost::container::flat_map requires operator =
if ( m_nThreadNo & 1 ) {
for ( size_t nPass = 0; nPass < nPassCount; ++nPass ) {
for ( key_array::const_iterator it = arr.begin(), itEnd = arr.end(); it != itEnd; ++it ) {
- if ( rMap.insert_with( *it, std::ref(func) ) )
+ if ( rMap.insert_with( *it, std::ref(func)))
++m_nInsertSuccess;
else
++m_nInsertFailed;
else {
for ( size_t nPass = 0; nPass < nPassCount; ++nPass ) {
for ( key_array::const_reverse_iterator it = arr.rbegin(), itEnd = arr.rend(); it != itEnd; ++it ) {
- if ( rMap.insert_with( *it, std::ref(func) ) )
+ if ( rMap.insert_with( *it, std::ref(func)))
++m_nInsertSuccess;
else
++m_nInsertFailed;
template <typename Key, typename Val>
void operator()( bool bNew, Key const& key, Val& v )
{
- std::unique_lock<typename value_type::lock_type> ac( v.m_access );
+ std::unique_lock<typename value_type::lock_type> ac( v.m_access );
if ( bNew ) {
++nCreated;
v.nKey = key;
if ( m_nThreadNo & 1 ) {
for ( size_t nPass = 0; nPass < nPassCount; ++nPass ) {
for ( key_array::const_iterator it = arr.begin(), itEnd = arr.end(); it != itEnd; ++it ) {
- //for ( size_t nItem = 0; nItem < c_nMapSize; ++nItem ) {
- std::pair<bool, bool> ret = rMap.update( *it, std::ref( func ) );
+ std::pair<bool, bool> ret = rMap.update( *it, std::ref( func ));
if ( ret.first ) {
if ( ret.second )
++m_nUpdateCreated;
else {
for ( size_t nPass = 0; nPass < nPassCount; ++nPass ) {
for ( key_array::const_reverse_iterator it = arr.rbegin(), itEnd = arr.rend(); it != itEnd; ++it ) {
- std::pair<bool, bool> ret = rMap.update( *it, std::ref( func ) );
+ std::pair<bool, bool> ret = rMap.update( *it, std::ref( func ));
if ( ret.first ) {
if ( ret.second )
++m_nUpdateCreated;
for ( size_t nPass = 0; nPass < nPassCount; ++nPass ) {
for ( key_array::const_iterator it = arr.begin(), itEnd = arr.end(); it != itEnd; ++it ) {
func.m_cnt.nKeyExpected = *it;
- if ( rMap.erase( *it, std::ref(func) ))
+ if ( rMap.erase( *it, std::ref(func)))
++m_nDeleteSuccess;
else
++m_nDeleteFailed;
for ( size_t nPass = 0; nPass < nPassCount; ++nPass ) {
for ( key_array::const_reverse_iterator it = arr.rbegin(), itEnd = arr.rend(); it != itEnd; ++it ) {
func.m_cnt.nKeyExpected = *it;
- if ( rMap.erase( *it, std::ref(func) ))
+ if ( rMap.erase( *it, std::ref(func)))
++m_nDeleteSuccess;
else
++m_nDeleteFailed;
m_arrValues.reserve( c_nMapSize );
for ( size_t i = 0; i < c_nMapSize; ++i )
m_arrValues.push_back( i );
- shuffle( m_arrValues.begin(), m_arrValues.end() );
+ shuffle( m_arrValues.begin(), m_arrValues.end());
CppUnitMini::ThreadPool pool( *this );
pool.add( new InserterThread( pool, testMap ), c_nInsertThreadCount );
pool.add( new DeleterThread( pool, testMap ), c_nDeleteThreadCount );
pool.add( new UpdaterThread( pool, testMap ), c_nUpdateThreadCount );
pool.run();
- CPPUNIT_MSG( " Duration=" << pool.avgDuration() );
+ CPPUNIT_MSG( " Duration=" << pool.avgDuration());
size_t nInsertSuccess = 0;
size_t nInsertFailed = 0;
for ( size_t nItem = 0; nItem < c_nMapSize; ++nItem ) {
testMap.erase( nItem );
}
- CPPUNIT_MSG( " Duration=" << timer.duration() );
- CPPUNIT_CHECK( testMap.empty() );
+ CPPUNIT_MSG( " Duration=" << timer.duration());
+ CPPUNIT_CHECK( testMap.empty());
additional_check( testMap );
print_stat( testMap );