template <typename K>
bool insert( K const& key )
{
- return insert_key( key, [](value_type&){} );
+ return insert_with( key, [](value_type&){} );
}
/// Inserts new node
template <typename K, typename V>
bool insert( K const& key, V const& val )
{
- return insert_key( key, [&val](value_type& item) { item.second = val ; } );
+ return insert_with( key, [&val](value_type& item) { item.second = val ; } );
}
/// Inserts new node and initialize it by a functor
it is preferable that the initialization should be completed only if inserting is successful.
*/
template <typename K, typename Func>
- bool insert_key( const K& key, Func func )
+ bool insert_with( const K& key, Func func )
{
scoped_node_ptr pNode( alloc_node( key ));
if ( base_class::insert( *pNode, [&func]( node_type& item ) { func( item.m_val ); } )) {
template <typename K>
bool insert( K const& key )
{
- return insert_key( key, [](value_type&){} );
+ return insert_with( key, [](value_type&){} );
}
/// Inserts new node
RCU \p synchronize() method can be called. RCU should not be locked.
*/
template <typename K, typename Func>
- bool insert_key( const K& key, Func func )
+ bool insert_with( const K& key, Func func )
{
scoped_node_ptr pNode( cxx_leaf_node_allocator().New( key ));
if ( base_class::insert( *pNode, [&func]( leaf_node& item ) { func( item.m_Value ); } )) {
template <typename K>
bool insert( K const& key )
{
- return insert_key( key, [](value_type&){} );
+ return insert_with( key, [](value_type&){} );
}
/// Inserts new node
it is preferable that the initialization should be completed only if inserting is successful.
*/
template <typename K, typename Func>
- bool insert_key( const K& key, Func func )
+ bool insert_with( const K& key, Func func )
{
scoped_node_ptr pNode( cxx_leaf_node_allocator().New( key ));
if ( base_class::insert( *pNode, [&func]( leaf_node& item ) { func( item.m_Value ); } )) {
it is preferable that the initialization should be completed only if inserting is successful.
*/
template <typename K, typename Func>
- bool insert_key( const K& key, Func func )
+ bool insert_with( const K& key, Func func )
{
- return insert_key_at( head(), key, func );
+ return insert_with_at( head(), key, func );
}
/// Inserts data of type \ref mapped_type constructed with <tt>std::forward<Args>(args)...</tt>
}
template <typename K, typename Func>
- bool insert_key_at( head_type& refHead, const K& key, Func f )
+ bool insert_with_at( head_type& refHead, const K& key, Func f )
{
scoped_node_ptr pNode( alloc_node( key ));
@warning See \ref cds_intrusive_item_creating "insert item troubleshooting"
*/
template <typename K, typename Func>
- bool insert_key( const K& key, Func func )
+ bool insert_with( const K& key, Func func )
{
- return insert_key_at( head(), key, func );
+ return insert_with_at( head(), key, func );
}
/// Ensures that the \p key exists in the list
}
template <typename K, typename Func>
- bool insert_key_at( head_type& refHead, const K& key, Func f )
+ bool insert_with_at( head_type& refHead, const K& key, Func f )
{
scoped_node_ptr pNode( alloc_node( key ));
template <typename K>
bool insert( K const& key )
{
- return insert_key( key, [](value_type&){} );
+ return insert_with( key, [](value_type&){} );
}
/// Inserts new node
template <typename K, typename V>
bool insert( K const& key, V const& val )
{
- return insert_key( key, [&val](value_type& item) { item.second = val ; } );
+ return insert_with( key, [&val](value_type& item) { item.second = val ; } );
}
/// Inserts new node and initialize it by a functor
it is preferable that the initialization should be completed only if inserting is successful.
*/
template <typename K, typename Func>
- bool insert_key( const K& key, Func func )
+ bool insert_with( const K& key, Func func )
{
scoped_node_ptr pNode( node_allocator().New( random_level(), key ));
if ( base_class::insert( *pNode, [&func]( node_type& item ) { func( item.m_Value ); } )) {
Returns an iterator pointed to inserted value, or \p end() if inserting is failed
*/
template <typename K, typename Func>
- iterator insert_key( const K& key, Func func )
+ iterator insert_with( const K& key, Func func )
{
- return node_to_iterator( insert_key_at( head(), key, func ));
+ return node_to_iterator( insert_with_at( head(), key, func ));
}
/// Ensures that the key \p key exists in the list
}
template <typename K, typename Func>
- node_type * insert_key_at( head_type& refHead, const K& key, Func f )
+ node_type * insert_with_at( head_type& refHead, const K& key, Func f )
{
scoped_node_ptr pNode( alloc_node( key ));
@warning See \ref cds_intrusive_item_creating "insert item troubleshooting"
*/
template <typename K, typename Func>
- bool insert_key( const K& key, Func func )
+ bool insert_with( const K& key, Func func )
{
- return insert_key_at( head(), key, func );
+ return insert_with_at( head(), key, func );
}
/// Inserts data of type \p mapped_type constructed from \p args
}
template <typename K, typename Func>
- bool insert_key_at( head_type& refHead, const K& key, Func f )
+ bool insert_with_at( head_type& refHead, const K& key, Func f )
{
scoped_node_ptr pNode( alloc_node( key ));
Returns an iterator pointed to inserted value, or \p end() if inserting is failed
*/
template <typename K, typename Func>
- iterator insert_key( const K& key, Func func )
+ iterator insert_with( const K& key, Func func )
{
- return node_to_iterator( insert_key_at( head(), key, func ));
+ return node_to_iterator( insert_with_at( head(), key, func ));
}
/// Ensures that the key \p key exists in the list
}
template <typename K, typename Func>
- node_type * insert_key_at( head_type& refHead, const K& key, Func f )
+ node_type * insert_with_at( head_type& refHead, const K& key, Func f )
{
scoped_node_ptr pNode( alloc_node( key ));
@warning See \ref cds_intrusive_item_creating "insert item troubleshooting"
*/
template <typename K, typename Func>
- bool insert_key( const K& key, Func func )
+ bool insert_with( const K& key, Func func )
{
- return insert_key_at( head(), key, func );
+ return insert_with_at( head(), key, func );
}
/// Ensures that the \p key exists in the list
}
template <typename K, typename Func>
- bool insert_key_at( head_type& refHead, const K& key, Func f )
+ bool insert_with_at( head_type& refHead, const K& key, Func f )
{
scoped_node_ptr pNode( alloc_node( key ));
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;
synchronization.
*/
template <typename K, typename Func>
- iterator insert_key( const K& key, Func func )
+ iterator insert_with( const K& key, Func func )
{
bucket_type& refBucket = bucket( key );
- bucket_iterator it = refBucket.insert_key( key, func );
+ bucket_iterator it = refBucket.insert_with( key, func );
if ( it != refBucket.end() ) {
++m_ItemCounter;
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;
Returns an iterator pointed to inserted value, or \p end() if inserting is failed
*/
template <typename K, typename Func>
- iterator insert_key( K const& key, Func func )
+ iterator insert_with( K const& key, Func func )
{
iterator it = insert( key );
if ( it != end() )
template <typename K>
bool insert( K const& key )
{
- return insert_key( key, [](value_type&){} );
+ return insert_with( key, [](value_type&){} );
}
/// Inserts new node
RCU \p synchronize method can be called. RCU should not be locked.
*/
template <typename K, typename Func>
- bool insert_key( const K& key, Func func )
+ bool insert_with( const K& key, Func func )
{
scoped_node_ptr pNode( node_allocator().New( random_level(), key ));
if ( base_class::insert( *pNode, [&func]( node_type& item ) { func( item.m_Value ); } )) {
synchronization.
*/
template <typename K, typename Func>
- bool insert_key( K const& key, Func func )
+ 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 );
Returns an iterator pointed to inserted value, or \p end() if inserting is failed
*/
template <typename K, typename Func>
- iterator insert_key( const K& key, Func func )
+ iterator insert_with( const K& key, Func func )
{
iterator it = insert( key );
if ( it != end() )
The function applies RCU lock internally.
*/
template <typename K, typename Func>
- bool insert_key( K const& key, Func func )
+ 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 );
template <typename K>
bool insert( K const& key )
{
- return insert_key( key, [](value_type&){} );
+ return insert_with( key, [](value_type&){} );
}
/// Inserts new node
template <typename K, typename V>
bool insert( K const& key, V const& val )
{
- return insert_key( key, [&val](value_type& item) { item.second = val ; } );
+ return insert_with( key, [&val](value_type& item) { item.second = val ; } );
}
/// Inserts new node and initialize it by a functor
it is preferable that the initialization should be completed only if inserting is successful.
*/
template <typename K, typename Func>
- bool insert_key( const K& key, Func func )
+ bool insert_with( const K& key, Func func )
{
return base_class::insert( key, func );
}
CPPUNIT_ASSERT( check_size( m, 2 ));
CPPUNIT_ASSERT( !m.find(30) );
- CPPUNIT_ASSERT( m.insert_key( 30, insert_functor<Map>() ) ) ; // value = 90
+ CPPUNIT_ASSERT( m.insert_with( 30, insert_functor<Map>() ) ) ; // value = 90
CPPUNIT_ASSERT( !m.empty() );
CPPUNIT_ASSERT( check_size( m, 3 ));
CPPUNIT_ASSERT( m.find(30) );
- CPPUNIT_ASSERT( !m.insert_key( 10, insert_functor<Map>() ) );
- CPPUNIT_ASSERT( !m.insert_key( 25, insert_functor<Map>() ) );
- CPPUNIT_ASSERT( !m.insert_key( 30, insert_functor<Map>() ) );
+ CPPUNIT_ASSERT( !m.insert_with( 10, insert_functor<Map>() ) );
+ CPPUNIT_ASSERT( !m.insert_with( 25, insert_functor<Map>() ) );
+ CPPUNIT_ASSERT( !m.insert_with( 30, insert_functor<Map>() ) );
// ensure (new key)
CPPUNIT_ASSERT( !m.find(27) );
CPPUNIT_ASSERT( check_size( m, 2 ));
CPPUNIT_ASSERT( !m.find(30) );
- CPPUNIT_ASSERT( m.insert_key( 30, insert_functor<Map>() ) ) ; // value = 90
+ CPPUNIT_ASSERT( m.insert_with( 30, insert_functor<Map>() ) ) ; // value = 90
CPPUNIT_ASSERT( !m.empty() );
CPPUNIT_ASSERT( check_size( m, 3 ));
CPPUNIT_ASSERT( m.find(30) );
- CPPUNIT_ASSERT( !m.insert_key( 10, insert_functor<Map>() ) );
- CPPUNIT_ASSERT( !m.insert_key( 25, insert_functor<Map>() ) );
- CPPUNIT_ASSERT( !m.insert_key( 30, insert_functor<Map>() ) );
+ CPPUNIT_ASSERT( !m.insert_with( 10, insert_functor<Map>() ) );
+ CPPUNIT_ASSERT( !m.insert_with( 25, insert_functor<Map>() ) );
+ CPPUNIT_ASSERT( !m.insert_with( 30, insert_functor<Map>() ) );
// ensure (new key)
CPPUNIT_ASSERT( !m.find(27) );
CPPUNIT_ASSERT( it->second.m_val == 200 );
CPPUNIT_ASSERT( m.find(55) == m.end() );
- it = m.insert_key( 55, insert_functor<Map>() );
+ it = m.insert_with( 55, insert_functor<Map>() );
CPPUNIT_ASSERT( it != m.end() );
CPPUNIT_ASSERT( !m.empty() );
CPPUNIT_ASSERT( check_size( m, 3 ));
CPPUNIT_ASSERT( m.insert( 55 ) == m.end() );
CPPUNIT_ASSERT( m.insert( 55, 10 ) == m.end() );
- CPPUNIT_ASSERT( m.insert_key( 55, insert_functor<Map>()) == m.end() );
+ CPPUNIT_ASSERT( m.insert_with( 55, insert_functor<Map>()) == m.end() );
CPPUNIT_ASSERT( m.find(10) != m.end() );
std::pair<iterator, bool> ensureResult = m.ensure( 10 );
CPPUNIT_ASSERT( it->second.m_val == 200 );
CPPUNIT_ASSERT( m.find(55) == m.end() );
- it = m.insert_key( 55, insert_functor<Map>() );
+ it = m.insert_with( 55, insert_functor<Map>() );
CPPUNIT_ASSERT( it != m.end() );
CPPUNIT_ASSERT( !m.empty() );
CPPUNIT_ASSERT( check_size( m, 3 ));
CPPUNIT_ASSERT( m.insert( 55 ) == m.end() );
CPPUNIT_ASSERT( m.insert( 55, 10 ) == m.end() );
- CPPUNIT_ASSERT( m.insert_key( 55, insert_functor<Map>()) == m.end() );
+ CPPUNIT_ASSERT( m.insert_with( 55, insert_functor<Map>()) == m.end() );
CPPUNIT_ASSERT( m.find(10) != m.end() );
std::pair<iterator, bool> ensureResult = m.ensure( 10 );
CPPUNIT_ASSERT( check_size( m, 2 ));
CPPUNIT_ASSERT( !m.find(30) );
- CPPUNIT_ASSERT( m.insert_key( 30, insert_functor<Map>() ) ) ; // value = 90
+ CPPUNIT_ASSERT( m.insert_with( 30, insert_functor<Map>() ) ) ; // value = 90
CPPUNIT_ASSERT( !m.empty() );
CPPUNIT_ASSERT( check_size( m, 3 ));
CPPUNIT_ASSERT( m.find(30) );
- CPPUNIT_ASSERT( !m.insert_key( 10, insert_functor<Map>() ) );
- CPPUNIT_ASSERT( !m.insert_key( 25, insert_functor<Map>() ) );
- CPPUNIT_ASSERT( !m.insert_key( 30, insert_functor<Map>() ) );
+ CPPUNIT_ASSERT( !m.insert_with( 10, insert_functor<Map>() ) );
+ CPPUNIT_ASSERT( !m.insert_with( 25, insert_functor<Map>() ) );
+ CPPUNIT_ASSERT( !m.insert_with( 30, insert_functor<Map>() ) );
// ensure (new key)
CPPUNIT_ASSERT( !m.find(27) );
CPPUNIT_ASSERT( check_size( m, 2 ));
CPPUNIT_ASSERT( !m.find(30) );
- CPPUNIT_ASSERT( m.insert_key( 30, insert_functor<Map>() ) ) ; // value = 90
+ CPPUNIT_ASSERT( m.insert_with( 30, insert_functor<Map>() ) ) ; // value = 90
CPPUNIT_ASSERT( !m.empty() );
CPPUNIT_ASSERT( check_size( m, 3 ));
CPPUNIT_ASSERT( m.find(30) );
- CPPUNIT_ASSERT( !m.insert_key( 10, insert_functor<Map>() ) );
- CPPUNIT_ASSERT( !m.insert_key( 25, insert_functor<Map>() ) );
- CPPUNIT_ASSERT( !m.insert_key( 30, insert_functor<Map>() ) );
+ CPPUNIT_ASSERT( !m.insert_with( 10, insert_functor<Map>() ) );
+ CPPUNIT_ASSERT( !m.insert_with( 25, insert_functor<Map>() ) );
+ CPPUNIT_ASSERT( !m.insert_with( 30, insert_functor<Map>() ) );
// ensure (new key)
CPPUNIT_ASSERT( !m.find(27) );
CPPUNIT_ASSERT( !l.empty() );
CPPUNIT_ASSERT( !l.find( 150 ));
- CPPUNIT_ASSERT( l.insert_key( 150, insert_functor() ));
+ CPPUNIT_ASSERT( l.insert_with( 150, insert_functor() ));
CPPUNIT_ASSERT( l.find( 150 ));
chk.m_nExpected = 1500;
CPPUNIT_ASSERT( l.find_with( 150, lt<key_type>(), std::ref( chk ) ) );
// erase test
CPPUNIT_ASSERT( !l.empty() );
- CPPUNIT_ASSERT( l.insert_key( 200, insert_functor() ));
+ CPPUNIT_ASSERT( l.insert_with( 200, insert_functor() ));
CPPUNIT_ASSERT( l.insert( 25 ));
CPPUNIT_ASSERT( l.erase( 100 ));
CPPUNIT_ASSERT( l.erase( 150 ));
CPPUNIT_ASSERT( !l.empty() );
CPPUNIT_ASSERT( l.find( 150 ) == l.end() );
- CPPUNIT_ASSERT( l.insert_key( 150, insert_functor() ) != l.end() );
+ CPPUNIT_ASSERT( l.insert_with( 150, insert_functor() ) != l.end() );
it = l.find( 150 );
CPPUNIT_ASSERT( it != l.end() );
CPPUNIT_ASSERT( it.key() == 150 );
CPPUNIT_ASSERT( !l.empty() );
CPPUNIT_ASSERT( !l.find( 150 ));
- CPPUNIT_ASSERT( l.insert_key( 150, insert_functor() ));
+ CPPUNIT_ASSERT( l.insert_with( 150, insert_functor() ));
CPPUNIT_ASSERT( l.find( 150 ));
chk.m_nExpected = 1500;
CPPUNIT_ASSERT( l.find( 150, std::ref( chk ) ) );
// erase test
CPPUNIT_ASSERT( !l.empty() );
- CPPUNIT_ASSERT( l.insert_key( 200, insert_functor() ));
+ CPPUNIT_ASSERT( l.insert_with( 200, insert_functor() ));
CPPUNIT_ASSERT( l.insert( 25 ));
CPPUNIT_ASSERT( l.erase( 100 ));
CPPUNIT_ASSERT( l.erase( 150 ));
CPPUNIT_ASSERT( !l.empty() );
CPPUNIT_ASSERT( l.find( 150 ) == l.end() );
- CPPUNIT_ASSERT( l.insert_key( 150, insert_functor() ) != l.end() );
+ CPPUNIT_ASSERT( l.insert_with( 150, insert_functor() ) != l.end() );
it = l.find( 150 );
CPPUNIT_ASSERT( it != l.end() );
CPPUNIT_ASSERT( it.key() == 150 );
CPPUNIT_ASSERT( check_size( m, 2 ));
CPPUNIT_ASSERT( !m.find(30) );
- CPPUNIT_ASSERT( m.insert_key( 30, insert_functor<Map>() ) ) ; // value = 90
+ CPPUNIT_ASSERT( m.insert_with( 30, insert_functor<Map>() ) ) ; // value = 90
CPPUNIT_ASSERT( !m.empty() );
CPPUNIT_ASSERT( check_size( m, 3 ));
CPPUNIT_ASSERT( m.find(30) );
- CPPUNIT_ASSERT( !m.insert_key( 10, insert_functor<Map>() ) );
- CPPUNIT_ASSERT( !m.insert_key( 25, insert_functor<Map>() ) );
- CPPUNIT_ASSERT( !m.insert_key( 30, insert_functor<Map>() ) );
+ CPPUNIT_ASSERT( !m.insert_with( 10, insert_functor<Map>() ) );
+ CPPUNIT_ASSERT( !m.insert_with( 25, insert_functor<Map>() ) );
+ CPPUNIT_ASSERT( !m.insert_with( 30, insert_functor<Map>() ) );
// ensure (new key)
CPPUNIT_ASSERT( !m.find(27) );
if ( m_nThreadNo & 1 ) {
for ( size_t nPass = 0; nPass < c_nThreadPassCount; ++nPass ) {
for ( key_array::const_iterator it = arr.begin(), itEnd = arr.end(); it != itEnd; ++it ) {
- if ( rMap.insert_key( *it, std::ref(func) ) )
+ if ( rMap.insert_with( *it, std::ref(func) ) )
++m_nInsertSuccess;
else
++m_nInsertFailed;
else {
for ( size_t nPass = 0; nPass < c_nThreadPassCount; ++nPass ) {
for ( key_array::const_reverse_iterator it = arr.rbegin(), itEnd = arr.rend(); it != itEnd; ++it ) {
- if ( rMap.insert_key( *it, std::ref(func) ) )
+ if ( rMap.insert_with( *it, std::ref(func) ) )
++m_nInsertSuccess;
else
++m_nInsertFailed;
}
template <typename K, typename Func>
- bool insert_key( K const& key, Func func )
+ bool insert_with( K const& key, Func func )
{
- return base_class::insert_key( key, func ) != base_class::end();
+ return base_class::insert_with( key, func ) != base_class::end();
}
template <typename K>
}
template <typename K, typename Func>
- bool insert_key( K const& key, Func func )
+ bool insert_with( K const& key, Func func )
{
- return base_class::insert_key( key, func ) != base_class::end();
+ return base_class::insert_with( key, func ) != base_class::end();
}
template <typename K>
}
template <typename K, typename Func>
- bool insert_key( K const& key, Func func )
+ bool insert_with( K const& key, Func func )
{
- return base_class::insert_key( key, func ) != base_class::end();
+ return base_class::insert_with( key, func ) != base_class::end();
}
template <typename K>