X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;ds=sidebyside;f=cds%2Fcontainer%2Fimpl%2Fbronson_avltree_map_rcu.h;h=f98febea9089819e1f1c1ed94d17111d8c1b5200;hb=8af78379ac30938f74feb5eda710050722235160;hp=515f289f58e44ec7029019a6941fe4cf7b6d4c33;hpb=d5080a8e05bbdc0db483fbe13b3c236d49ba6262;p=libcds.git diff --git a/cds/container/impl/bronson_avltree_map_rcu.h b/cds/container/impl/bronson_avltree_map_rcu.h index 515f289f..f98febea 100644 --- a/cds/container/impl/bronson_avltree_map_rcu.h +++ b/cds/container/impl/bronson_avltree_map_rcu.h @@ -295,13 +295,6 @@ namespace cds { namespace container { return std::make_pair( result != 0, (result & update_flags::result_inserted) != 0 ); } - //@cond - template - std::pair ensure( K const& key, mapped_type pVal ) - { - return update( key, pVal, true ); - } - //@endcond /// Delete \p key from the map @@ -621,7 +614,7 @@ namespace cds { namespace container { ); } - /// Find the key \p key + /// 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. @@ -629,20 +622,19 @@ namespace cds { namespace container { The function applies RCU lock internally. */ template - bool find( K const& key ) + bool contains( K const& key ) { return do_find( key, key_comparator(), []( node_type * ) -> bool { return true; }); } - /// 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 \p find(K const&) - but \p pred is used for key comparing. + The function is similar to contains( key ) 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 - bool find_with( K const& key, Less pred ) + bool contains( K const& key, Less pred ) { CDS_UNUSED( pred ); return do_find( key, cds::opt::details::make_comparator_from_less(), []( node_type * ) -> bool { return true; } ); @@ -1470,6 +1462,7 @@ namespace cds { namespace container { } if ( bInserted ) { + ++m_ItemCounter; m_stat.onInsertSuccess(); return update_flags::result_inserted; } @@ -1487,8 +1480,8 @@ namespace cds { namespace container { if ( !pNode->is_valued( memory_model::memory_order_acquire ) ) return update_flags::failed; - if ( child( pNode, left_child, memory_model::memory_order_acquire ) == nullptr - || child( pNode, right_child, memory_model::memory_order_acquire ) == nullptr ) + if ( child( pNode, left_child, memory_model::memory_order_acquire ) == nullptr + || child( pNode, right_child, memory_model::memory_order_acquire ) == nullptr ) { // pNode can be replaced with its child @@ -1682,7 +1675,7 @@ namespace cds { namespace container { } } - assert( child( pParent, left_child, memory_model::memory_order_relaxed ) == pNode + assert( child( pParent, left_child, memory_model::memory_order_relaxed ) == pNode || child( pParent, right_child, memory_model::memory_order_relaxed ) == pNode ); int h = height( pNode, memory_model::memory_order_acquire ); @@ -1708,7 +1701,7 @@ namespace cds { namespace container { node_type * rebalance_to_right_locked( node_type * pParent, node_type * pNode, node_type * pLeft, int hR ) { assert( parent( pNode, memory_model::memory_order_relaxed ) == pParent ); - assert( child( pParent, left_child, memory_model::memory_order_relaxed ) == pNode + assert( child( pParent, left_child, memory_model::memory_order_relaxed ) == pNode || child( pParent, right_child, memory_model::memory_order_relaxed ) == pNode ); // pParent and pNode is locked yet @@ -1762,7 +1755,7 @@ namespace cds { namespace container { node_type * rebalance_to_left_locked( node_type * pParent, node_type * pNode, node_type * pRight, int hL ) { assert( parent( pNode, memory_model::memory_order_relaxed ) == pParent ); - assert( child( pParent, left_child, memory_model::memory_order_relaxed ) == pNode + assert( child( pParent, left_child, memory_model::memory_order_relaxed ) == pNode || child( pParent, right_child, memory_model::memory_order_relaxed ) == pNode ); // pParent and pNode is locked yet