item.second.nVal = item.first * 3;
}
- // ensure ftor
+ // update ftor
void operator()( bool bNew, pair_type& item )
{
if ( bNew )
template <class Map>
void test_with( Map& m )
{
- std::pair<bool, bool> ensureResult;
+ std::pair<bool, bool> updateResult;
// insert
CPPUNIT_ASSERT( m.empty() );
CPPUNIT_ASSERT( check_size( m, 0 ));
- CPPUNIT_ASSERT( !m.find(25) );
+ CPPUNIT_ASSERT( !m.contains(25) );
CPPUNIT_ASSERT( m.insert( 25 ) ) ; // value = 0
- CPPUNIT_ASSERT( m.find(25) );
+ CPPUNIT_ASSERT( m.contains(25) );
CPPUNIT_ASSERT( !m.empty() );
CPPUNIT_ASSERT( check_size( m, 1 ));
- CPPUNIT_ASSERT( m.find(25) );
+ CPPUNIT_ASSERT( m.contains(25) );
CPPUNIT_ASSERT( !m.insert( 25 ) );
CPPUNIT_ASSERT( !m.empty() );
CPPUNIT_ASSERT( check_size( m, 1 ));
- CPPUNIT_ASSERT( !m.find_with(10, less()) );
+ CPPUNIT_ASSERT( !m.contains(10, less()) );
CPPUNIT_ASSERT( m.insert( 10, 10 ) );
CPPUNIT_ASSERT( !m.empty() );
CPPUNIT_ASSERT( check_size( m, 2 ));
- CPPUNIT_ASSERT( m.find_with(10, less()) );
+ CPPUNIT_ASSERT( m.contains(10, less()) );
CPPUNIT_ASSERT( !m.insert( 10, 20 ) );
CPPUNIT_ASSERT( !m.empty() );
CPPUNIT_ASSERT( check_size( m, 2 ));
- CPPUNIT_ASSERT( !m.find(30) );
+ CPPUNIT_ASSERT( !m.contains(30) );
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.contains(30) );
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) );
- ensureResult = m.ensure( 27, insert_functor<Map>() ) ; // value = 54
- CPPUNIT_ASSERT( ensureResult.first );
- CPPUNIT_ASSERT( ensureResult.second );
- CPPUNIT_ASSERT( m.find(27) );
+ // update (new key)
+ CPPUNIT_ASSERT( !m.contains(27) );
+ updateResult = m.update( 27, insert_functor<Map>(), false ) ; // value = 54
+ CPPUNIT_ASSERT( !updateResult.first );
+ CPPUNIT_ASSERT( !updateResult.second );
+ CPPUNIT_ASSERT( !m.contains(27) );
+ updateResult = m.update( 27, insert_functor<Map>(), false ) ; // value = 54
+ CPPUNIT_ASSERT( updateResult.first );
+ CPPUNIT_ASSERT( updateResult.second );
+ CPPUNIT_ASSERT( m.contains(27) );
// find test
check_value chk(10);
chk.m_nExpected = 54;
CPPUNIT_ASSERT( m.find( 27, std::ref( chk ) ) );
- ensureResult = m.ensure( 10, insert_functor<Map>() ) ; // value = 50
- CPPUNIT_ASSERT( ensureResult.first );
- CPPUNIT_ASSERT( !ensureResult.second );
+ updateResult = m.update( 10, insert_functor<Map>() ) ; // value = 50
+ CPPUNIT_ASSERT( updateResult.first );
+ CPPUNIT_ASSERT( !updateResult.second );
chk.m_nExpected = 50;
CPPUNIT_ASSERT( m.find( 10, std::ref( chk ) ) );
// erase test
- CPPUNIT_ASSERT( !m.find(100) );
+ CPPUNIT_ASSERT( !m.contains(100) );
CPPUNIT_ASSERT( !m.erase( 100 )) ; // not found
- CPPUNIT_ASSERT( m.find(25) );
+ CPPUNIT_ASSERT( m.contains(25) );
CPPUNIT_ASSERT( check_size( m, 4 ));
CPPUNIT_ASSERT( m.erase( 25 ));
CPPUNIT_ASSERT( !m.empty() );
CPPUNIT_ASSERT( check_size( m, 3 ));
- CPPUNIT_ASSERT( !m.find(25) );
+ CPPUNIT_ASSERT( !m.contains(25) );
CPPUNIT_ASSERT( !m.erase( 25 ));
- CPPUNIT_ASSERT( !m.find(258) );
+ CPPUNIT_ASSERT( !m.contains(258) );
CPPUNIT_ASSERT( m.insert(258))
CPPUNIT_ASSERT( check_size( m, 4 ));
- CPPUNIT_ASSERT( m.find_with(258, less()) );
+ CPPUNIT_ASSERT( m.contains(258, less()) );
CPPUNIT_ASSERT( m.erase_with( 258, less() ));
CPPUNIT_ASSERT( !m.empty() );
CPPUNIT_ASSERT( check_size( m, 3 ));
- CPPUNIT_ASSERT( !m.find(258) );
+ CPPUNIT_ASSERT( !m.contains(258) );
CPPUNIT_ASSERT( !m.erase_with( 258, less() ));
int nVal;
extract_functor ext;
ext.m_pVal = &nVal;
- CPPUNIT_ASSERT( !m.find(29) );
+ CPPUNIT_ASSERT( !m.contains(29) );
CPPUNIT_ASSERT( m.insert(29, 290));
CPPUNIT_ASSERT( check_size( m, 4 ));
CPPUNIT_ASSERT( m.erase_with( 29, less(), std::ref( ext ) ) );
++i.stat.nEnsureExistFuncCall;
}
- struct ensure_functor
+ struct update_functor
{
template <typename Q>
void operator()( bool bNew, value_type& i, Q& val )
int key;
// insert/find test
- CPPUNIT_ASSERT( !s.find( 10 ) );
+ CPPUNIT_ASSERT( !s.contains( 10 ) );
CPPUNIT_ASSERT( s.insert( 10 ));
CPPUNIT_ASSERT( !s.empty() );
CPPUNIT_ASSERT( check_size( s, 1 ));
- CPPUNIT_ASSERT( s.find( 10 ) );
+ CPPUNIT_ASSERT( s.contains( 10 ) );
CPPUNIT_ASSERT( !s.insert( 10 ));
CPPUNIT_ASSERT( !s.empty() );
CPPUNIT_ASSERT( check_size( s, 1 ));
- CPPUNIT_ASSERT( !s.find_with( 20, less() ) );
+ CPPUNIT_ASSERT( !s.contains( 20, less() ) );
CPPUNIT_ASSERT( s.insert( std::make_pair(20, 25) ));
CPPUNIT_ASSERT( !s.empty() );
CPPUNIT_ASSERT( check_size( s, 2 ));
- CPPUNIT_ASSERT( s.find_with( 10, less() ) );
- CPPUNIT_ASSERT( s.find( key = 20 ) );
+ CPPUNIT_ASSERT( s.contains( 10, less() ) );
+ CPPUNIT_ASSERT( s.contains( key = 20 ) );
CPPUNIT_ASSERT( s.find_with( key, less(), find_functor() ) );
{
copy_found<value_type> f;
CPPUNIT_ASSERT( !s.empty() );
CPPUNIT_ASSERT( check_size( s, 2 ));
- CPPUNIT_ASSERT( !s.find( 25 ) );
+ CPPUNIT_ASSERT( !s.contains( 25 ) );
CPPUNIT_ASSERT( s.insert( std::make_pair(25, -1), insert_functor() ));
CPPUNIT_ASSERT( !s.empty() );
CPPUNIT_ASSERT( check_size( s, 3 ));
CPPUNIT_ASSERT( f.m_found.stat.nInsertFuncCall == 1 );
}
- // ensure test
+ // update test
key = 10;
{
copy_found<value_type> f;
CPPUNIT_ASSERT( f.m_found.stat.nEnsureExistFuncCall == 0 );
CPPUNIT_ASSERT( f.m_found.stat.nEnsureNewFuncCall == 0 );
}
- std::pair<bool, bool> ensureResult = s.ensure( key, ensure_functor() );
- CPPUNIT_ASSERT( ensureResult.first && !ensureResult.second );
+ std::pair<bool, bool> updateResult = s.update( key, update_functor(), false );
+ CPPUNIT_ASSERT( updateResult.first && !updateResult.second );
CPPUNIT_ASSERT( !s.empty() );
CPPUNIT_ASSERT( check_size( s, 3 ));
{
CPPUNIT_ASSERT( f.m_found.stat.nEnsureNewFuncCall == 0 );
}
- ensureResult = s.ensure( std::make_pair(13, 1300), ensure_functor() );
- CPPUNIT_ASSERT( ensureResult.first && ensureResult.second );
+ updateResult = s.update( std::make_pair(13, 1300), update_functor(), false );
+ CPPUNIT_ASSERT( !updateResult.first && !updateResult.second );
+ updateResult = s.update( std::make_pair(13, 1300), update_functor());
+ CPPUNIT_ASSERT( updateResult.first && updateResult.second );
CPPUNIT_ASSERT( !s.empty() );
CPPUNIT_ASSERT( check_size( s, 4 ));
{
// erase test
CPPUNIT_ASSERT( s.erase(13) );
- CPPUNIT_ASSERT( !s.find( 13 ));
+ CPPUNIT_ASSERT( !s.contains( 13 ));
CPPUNIT_ASSERT( !s.empty() );
CPPUNIT_ASSERT( check_size( s, 3 ));
CPPUNIT_ASSERT( !s.erase(13) );
CPPUNIT_ASSERT( !s.empty() );
CPPUNIT_ASSERT( check_size( s, 3 ));
- CPPUNIT_ASSERT( s.find( 10 ));
+ CPPUNIT_ASSERT( s.contains( 10 ));
CPPUNIT_ASSERT( s.erase_with( 10, less() ));
- CPPUNIT_ASSERT( !s.find( 10 ));
+ CPPUNIT_ASSERT( !s.contains( 10 ));
CPPUNIT_ASSERT( !s.empty() );
CPPUNIT_ASSERT( check_size( s, 2 ));
CPPUNIT_ASSERT( !s.erase_with(10, less()) );
CPPUNIT_ASSERT( !s.empty() );
CPPUNIT_ASSERT( check_size( s, 2 ));
- CPPUNIT_ASSERT( s.find(20) );
+ CPPUNIT_ASSERT( s.contains(20) );
{
copy_found<value_type> f;
f.m_found.nKey = 0;
CPPUNIT_ASSERT( f.m_found.nKey == 235 );
CPPUNIT_ASSERT( f.m_found.nVal == 2350 );
}
- CPPUNIT_ASSERT( !s.find( 20 ));
+ CPPUNIT_ASSERT( !s.contains( 20 ));
CPPUNIT_ASSERT( !s.empty() );
CPPUNIT_ASSERT( check_size( s, 1 ));
CPPUNIT_ASSERT( !s.empty() );
CPPUNIT_ASSERT( check_size( s, 3 ));
- CPPUNIT_ASSERT( s.find(151));
- CPPUNIT_ASSERT( s.find_with(174, less()));
- CPPUNIT_ASSERT( s.find(190));
+ CPPUNIT_ASSERT( s.contains(151));
+ CPPUNIT_ASSERT( s.contains(174, less()));
+ CPPUNIT_ASSERT( s.contains(190));
{
copy_found<value_type> f;
}
};
- struct ensure_functor {
+ struct update_functor {
template <typename T>
void operator()( bool bNew, T& dest, T& src) const
{
value_type v4( 25, 250 );
value_type v5( -50, -500 );
- // insert/ensure
+ // insert/update
CPPUNIT_ASSERT( t.empty() );
CPPUNIT_ASSERT( misc::check_size( t, 0 ));
- CPPUNIT_CHECK( !t.find( v1.nKey ));
- CPPUNIT_CHECK( !t.find( v1 ));
- CPPUNIT_CHECK( !t.find( v2.nKey ));
- CPPUNIT_CHECK( !t.find( v2 ));
- CPPUNIT_CHECK( !t.find( v3.nKey ));
- CPPUNIT_CHECK( !t.find( v3 ));
- CPPUNIT_CHECK( !t.find( v4.nKey ));
- CPPUNIT_CHECK( !t.find( v4 ));
- CPPUNIT_CHECK( !t.find( v5.nKey ));
- CPPUNIT_CHECK( !t.find( v5 ));
+ CPPUNIT_CHECK( !t.contains( v1.nKey ));
+ CPPUNIT_CHECK( !t.contains( v1 ));
+ CPPUNIT_CHECK( !t.contains( v2.nKey ));
+ CPPUNIT_CHECK( !t.contains( v2 ));
+ CPPUNIT_CHECK( !t.contains( v3.nKey ));
+ CPPUNIT_CHECK( !t.contains( v3 ));
+ CPPUNIT_CHECK( !t.contains( v4.nKey ));
+ CPPUNIT_CHECK( !t.contains( v4 ));
+ CPPUNIT_CHECK( !t.contains( v5.nKey ));
+ CPPUNIT_CHECK( !t.contains( v5 ));
CPPUNIT_ASSERT( t.insert( v1 ));
CPPUNIT_ASSERT( t.check_consistency() );
CPPUNIT_ASSERT( !t.empty() );
CPPUNIT_ASSERT( misc::check_size( t, 1 ));
- CPPUNIT_CHECK( t.find( v1.nKey ));
- CPPUNIT_CHECK( t.find( v1 ));
- CPPUNIT_CHECK( !t.find( v2.nKey ));
- CPPUNIT_CHECK( !t.find( v2 ));
- CPPUNIT_CHECK( !t.find( v3.nKey ));
- CPPUNIT_CHECK( !t.find( v3 ));
- CPPUNIT_CHECK( !t.find( v4.nKey ));
- CPPUNIT_CHECK( !t.find( v4 ));
- CPPUNIT_CHECK( !t.find( v5.nKey ));
- CPPUNIT_CHECK( !t.find( v5 ));
+ CPPUNIT_CHECK( t.contains( v1.nKey ));
+ CPPUNIT_CHECK( t.contains( v1 ));
+ CPPUNIT_CHECK( !t.contains( v2.nKey ));
+ CPPUNIT_CHECK( !t.contains( v2 ));
+ CPPUNIT_CHECK( !t.contains( v3.nKey ));
+ CPPUNIT_CHECK( !t.contains( v3 ));
+ CPPUNIT_CHECK( !t.contains( v4.nKey ));
+ CPPUNIT_CHECK( !t.contains( v4 ));
+ CPPUNIT_CHECK( !t.contains( v5.nKey ));
+ CPPUNIT_CHECK( !t.contains( v5 ));
CPPUNIT_ASSERT( v2.stat.nInsertFuncCall == 0 );
CPPUNIT_ASSERT( t.insert( v2, insert_functor() ));
CPPUNIT_ASSERT( t.check_consistency() );
CPPUNIT_ASSERT( v2.stat.nInsertFuncCall == 1 );
- CPPUNIT_ASSERT( t.find( v1.nKey ));
- CPPUNIT_ASSERT( t.find( v1 ));
- CPPUNIT_ASSERT( t.find( v2.nKey ));
- CPPUNIT_ASSERT( t.find( v2 ));
- CPPUNIT_ASSERT( !t.find( v3.nKey ));
- CPPUNIT_ASSERT( !t.find( v3 ));
- CPPUNIT_ASSERT( !t.find( v4.nKey ));
- CPPUNIT_ASSERT( !t.find( v4 ));
- CPPUNIT_ASSERT( !t.find( v5.nKey ));
- CPPUNIT_ASSERT( !t.find( v5 ));
+ CPPUNIT_ASSERT( t.contains( v1.nKey ));
+ CPPUNIT_ASSERT( t.contains( v1 ));
+ CPPUNIT_ASSERT( t.contains( v2.nKey ));
+ CPPUNIT_ASSERT( t.contains( v2 ));
+ CPPUNIT_ASSERT( !t.contains( v3.nKey ));
+ CPPUNIT_ASSERT( !t.contains( v3 ));
+ CPPUNIT_ASSERT( !t.contains( v4.nKey ));
+ CPPUNIT_ASSERT( !t.contains( v4 ));
+ CPPUNIT_ASSERT( !t.contains( v5.nKey ));
+ CPPUNIT_ASSERT( !t.contains( v5 ));
CPPUNIT_ASSERT( !t.empty() );
CPPUNIT_ASSERT( misc::check_size( t, 2 ));
+ std::pair<bool, bool> updateResult;
CPPUNIT_ASSERT( v3.stat.nEnsureNewFuncCall == 0 );
CPPUNIT_ASSERT( v3.stat.nEnsureExistFuncCall == 0 );
- CPPUNIT_ASSERT( t.ensure( v3, ensure_functor() ).second );
+ updateResult = t.update( v3, update_functor(), false );
+ CPPUNIT_ASSERT( !updateResult.first && !updateResult.second );
+ CPPUNIT_ASSERT( v3.stat.nEnsureNewFuncCall == 0 );
+ CPPUNIT_ASSERT( v3.stat.nEnsureExistFuncCall == 0 );
+ updateResult = t.update( v3, update_functor(), true );
+ CPPUNIT_ASSERT( updateResult.first && updateResult.second );
CPPUNIT_ASSERT( t.check_consistency() );
CPPUNIT_ASSERT( v3.stat.nEnsureNewFuncCall == 1 );
CPPUNIT_ASSERT( v3.stat.nEnsureExistFuncCall == 0 );
CPPUNIT_ASSERT( v3.nValue == 300 );
- CPPUNIT_ASSERT( !t.ensure( v3, ensure_functor() ).second );
+ updateResult = t.update( v3, update_functor(), false );
+ CPPUNIT_ASSERT( updateResult.first && !updateResult.second );
CPPUNIT_ASSERT( v3.stat.nEnsureNewFuncCall == 1 );
CPPUNIT_ASSERT( v3.stat.nEnsureExistFuncCall == 1 );
CPPUNIT_ASSERT( v3.nValue == 600 );
- CPPUNIT_ASSERT( t.find( v1.nKey ));
- CPPUNIT_ASSERT( t.find( v1 ));
- CPPUNIT_ASSERT( t.find( v2.nKey ));
- CPPUNIT_ASSERT( t.find( v2 ));
- CPPUNIT_ASSERT( t.find( v3.nKey ));
- CPPUNIT_ASSERT( t.find( v3 ));
- CPPUNIT_ASSERT( !t.find( v4.nKey ));
- CPPUNIT_ASSERT( !t.find( v4 ));
- CPPUNIT_ASSERT( !t.find( v5.nKey ));
- CPPUNIT_ASSERT( !t.find( v5 ));
+ CPPUNIT_ASSERT( t.contains( v1.nKey ));
+ CPPUNIT_ASSERT( t.contains( v1 ));
+ CPPUNIT_ASSERT( t.contains( v2.nKey ));
+ CPPUNIT_ASSERT( t.contains( v2 ));
+ CPPUNIT_ASSERT( t.contains( v3.nKey ));
+ CPPUNIT_ASSERT( t.contains( v3 ));
+ CPPUNIT_ASSERT( !t.contains( v4.nKey ));
+ CPPUNIT_ASSERT( !t.contains( v4 ));
+ CPPUNIT_ASSERT( !t.contains( v5.nKey ));
+ CPPUNIT_ASSERT( !t.contains( v5 ));
CPPUNIT_ASSERT( !t.empty() );
CPPUNIT_ASSERT( misc::check_size( t, 3 ));
CPPUNIT_ASSERT( v3.stat.nEnsureNewFuncCall == 1 );
CPPUNIT_ASSERT( v3.stat.nEnsureExistFuncCall == 1 );
CPPUNIT_ASSERT( v3.nValue == 600 );
- CPPUNIT_ASSERT( !t.ensure( v, ensure_functor() ).second );
+ CPPUNIT_ASSERT( !t.update( v, update_functor() ).second );
CPPUNIT_ASSERT( v3.stat.nEnsureNewFuncCall == 1 );
CPPUNIT_ASSERT( v.stat.nEnsureExistFuncCall == 1 );
CPPUNIT_ASSERT( v3.nValue == 1200 );
CPPUNIT_ASSERT( t.insert( v4 ));
CPPUNIT_ASSERT( t.check_consistency() );
- CPPUNIT_ASSERT( t.find( v1.nKey ));
- CPPUNIT_ASSERT( t.find( v1 ));
- CPPUNIT_ASSERT( t.find( v2.nKey ));
- CPPUNIT_ASSERT( t.find( v2 ));
- CPPUNIT_ASSERT( t.find( v3.nKey ));
- CPPUNIT_ASSERT( t.find( v3 ));
- CPPUNIT_ASSERT( t.find( v4.nKey ));
- CPPUNIT_ASSERT( t.find( v4 ));
- CPPUNIT_ASSERT( !t.find( v5.nKey ));
- CPPUNIT_ASSERT( !t.find( v5 ));
+ CPPUNIT_ASSERT( t.contains( v1.nKey ));
+ CPPUNIT_ASSERT( t.contains( v1 ));
+ CPPUNIT_ASSERT( t.contains( v2.nKey ));
+ CPPUNIT_ASSERT( t.contains( v2 ));
+ CPPUNIT_ASSERT( t.contains( v3.nKey ));
+ CPPUNIT_ASSERT( t.contains( v3 ));
+ CPPUNIT_ASSERT( t.contains( v4.nKey ));
+ CPPUNIT_ASSERT( t.contains( v4 ));
+ CPPUNIT_ASSERT( !t.contains( v5.nKey ));
+ CPPUNIT_ASSERT( !t.contains( v5 ));
CPPUNIT_ASSERT( !t.empty() );
CPPUNIT_ASSERT( misc::check_size( t, 4 ));
CPPUNIT_ASSERT( t.insert( v5 ));
CPPUNIT_ASSERT( t.check_consistency() );
- CPPUNIT_ASSERT( t.find( v1.nKey ));
- CPPUNIT_ASSERT( t.find( v1 ));
- CPPUNIT_ASSERT( t.find( v2.nKey ));
- CPPUNIT_ASSERT( t.find( v2 ));
- CPPUNIT_ASSERT( t.find( v3.nKey ));
- CPPUNIT_ASSERT( t.find( v3 ));
- CPPUNIT_ASSERT( t.find( v4.nKey ));
- CPPUNIT_ASSERT( t.find( v4 ));
- CPPUNIT_ASSERT( t.find( v5.nKey ));
- CPPUNIT_ASSERT( t.find( v5 ));
+ CPPUNIT_ASSERT( t.contains( v1.nKey ));
+ CPPUNIT_ASSERT( t.contains( v1 ));
+ CPPUNIT_ASSERT( t.contains( v2.nKey ));
+ CPPUNIT_ASSERT( t.contains( v2 ));
+ CPPUNIT_ASSERT( t.contains( v3.nKey ));
+ CPPUNIT_ASSERT( t.contains( v3 ));
+ CPPUNIT_ASSERT( t.contains( v4.nKey ));
+ CPPUNIT_ASSERT( t.contains( v4 ));
+ CPPUNIT_ASSERT( t.contains( v5.nKey ));
+ CPPUNIT_ASSERT( t.contains( v5 ));
CPPUNIT_ASSERT( !t.empty() );
CPPUNIT_ASSERT( misc::check_size( t, 5 ));
++v1.stat.nWaitingDispCount;
CPPUNIT_ASSERT( t.unlink(v1));
CPPUNIT_ASSERT( t.check_consistency() );
- CPPUNIT_ASSERT( !t.find( v1.nKey ));
- CPPUNIT_ASSERT( !t.find( v1 ));
+ CPPUNIT_ASSERT( !t.contains( v1.nKey ));
+ CPPUNIT_ASSERT( !t.contains( v1 ));
CPPUNIT_ASSERT( !t.unlink(v1));
- CPPUNIT_ASSERT( t.find( v2.nKey ));
- CPPUNIT_ASSERT( t.find( v2 ));
- CPPUNIT_ASSERT( t.find( v3.nKey ));
- CPPUNIT_ASSERT( t.find( v3 ));
- CPPUNIT_ASSERT( t.find( v4.nKey ));
- CPPUNIT_ASSERT( t.find( v4 ));
- CPPUNIT_ASSERT( t.find( v5.nKey ));
- CPPUNIT_ASSERT( t.find( v5 ));
+ CPPUNIT_ASSERT( t.contains( v2.nKey ));
+ CPPUNIT_ASSERT( t.contains( v2 ));
+ CPPUNIT_ASSERT( t.contains( v3.nKey ));
+ CPPUNIT_ASSERT( t.contains( v3 ));
+ CPPUNIT_ASSERT( t.contains( v4.nKey ));
+ CPPUNIT_ASSERT( t.contains( v4 ));
+ CPPUNIT_ASSERT( t.contains( v5.nKey ));
+ CPPUNIT_ASSERT( t.contains( v5 ));
CPPUNIT_ASSERT( !t.empty() );
CPPUNIT_ASSERT( misc::check_size( t, 4 ));
++v2.stat.nWaitingDispCount;
CPPUNIT_ASSERT( t.erase( v2.nKey ));
CPPUNIT_ASSERT( t.check_consistency() );
- CPPUNIT_ASSERT( !t.find( v1.nKey ));
- CPPUNIT_ASSERT( !t.find( v1 ));
- CPPUNIT_ASSERT( !t.find( v2.nKey ));
- CPPUNIT_ASSERT( !t.find( v2 ));
+ CPPUNIT_ASSERT( !t.contains( v1.nKey ));
+ CPPUNIT_ASSERT( !t.contains( v1 ));
+ CPPUNIT_ASSERT( !t.contains( v2.nKey ));
+ CPPUNIT_ASSERT( !t.contains( v2 ));
CPPUNIT_ASSERT( !t.erase(v2));
- CPPUNIT_ASSERT( t.find( v3.nKey ));
- CPPUNIT_ASSERT( t.find( v3 ));
- CPPUNIT_ASSERT( t.find( v4.nKey ));
- CPPUNIT_ASSERT( t.find( v4 ));
- CPPUNIT_ASSERT( t.find( v5.nKey ));
- CPPUNIT_ASSERT( t.find( v5 ));
+ CPPUNIT_ASSERT( t.contains( v3.nKey ));
+ CPPUNIT_ASSERT( t.contains( v3 ));
+ CPPUNIT_ASSERT( t.contains( v4.nKey ));
+ CPPUNIT_ASSERT( t.contains( v4 ));
+ CPPUNIT_ASSERT( t.contains( v5.nKey ));
+ CPPUNIT_ASSERT( t.contains( v5 ));
CPPUNIT_ASSERT( !t.empty() );
CPPUNIT_ASSERT( misc::check_size( t, 3 ));
++v3.stat.nWaitingDispCount;
CPPUNIT_ASSERT( t.erase_with( v3.nKey, less<value_type>() ));
CPPUNIT_ASSERT( t.check_consistency() );
- CPPUNIT_ASSERT( !t.find( v1.nKey ));
- CPPUNIT_ASSERT( !t.find( v1 ));
- CPPUNIT_ASSERT( !t.find( v2.nKey ));
- CPPUNIT_ASSERT( !t.find( v2 ));
- CPPUNIT_ASSERT( !t.find( v3.nKey ));
- CPPUNIT_ASSERT( !t.find( v3 ));
+ CPPUNIT_ASSERT( !t.contains( v1.nKey ));
+ CPPUNIT_ASSERT( !t.contains( v1 ));
+ CPPUNIT_ASSERT( !t.contains( v2.nKey ));
+ CPPUNIT_ASSERT( !t.contains( v2 ));
+ CPPUNIT_ASSERT( !t.contains( v3.nKey ));
+ CPPUNIT_ASSERT( !t.contains( v3 ));
CPPUNIT_ASSERT( !t.erase_with(v3, less<value_type>() ));
- CPPUNIT_ASSERT( t.find( v4.nKey ));
- CPPUNIT_ASSERT( t.find( v4 ));
- CPPUNIT_ASSERT( t.find( v5.nKey ));
- CPPUNIT_ASSERT( t.find( v5 ));
+ CPPUNIT_ASSERT( t.contains( v4.nKey ));
+ CPPUNIT_ASSERT( t.contains( v4 ));
+ CPPUNIT_ASSERT( t.contains( v5.nKey ));
+ CPPUNIT_ASSERT( t.contains( v5 ));
CPPUNIT_ASSERT( !t.empty() );
CPPUNIT_ASSERT( misc::check_size( t, 2 ));
CPPUNIT_ASSERT( t.erase( v4.nKey, erase_functor() ));
CPPUNIT_ASSERT( t.check_consistency() );
CPPUNIT_ASSERT( v4.stat.nEraseFuncCall == 1 );
- CPPUNIT_ASSERT( !t.find( v1.nKey ));
- CPPUNIT_ASSERT( !t.find( v1 ));
- CPPUNIT_ASSERT( !t.find( v2.nKey ));
- CPPUNIT_ASSERT( !t.find( v2 ));
- CPPUNIT_ASSERT( !t.find( v3.nKey ));
- CPPUNIT_ASSERT( !t.find( v3 ));
- CPPUNIT_ASSERT( !t.find( v4.nKey ));
- CPPUNIT_ASSERT( !t.find( v4 ));
+ CPPUNIT_ASSERT( !t.contains( v1.nKey ));
+ CPPUNIT_ASSERT( !t.contains( v1 ));
+ CPPUNIT_ASSERT( !t.contains( v2.nKey ));
+ CPPUNIT_ASSERT( !t.contains( v2 ));
+ CPPUNIT_ASSERT( !t.contains( v3.nKey ));
+ CPPUNIT_ASSERT( !t.contains( v3 ));
+ CPPUNIT_ASSERT( !t.contains( v4.nKey ));
+ CPPUNIT_ASSERT( !t.contains( v4 ));
CPPUNIT_ASSERT( !t.erase( v4.nKey, erase_functor() ));
CPPUNIT_ASSERT( v4.stat.nEraseFuncCall == 1 );
- CPPUNIT_ASSERT( t.find( v5.nKey ));
- CPPUNIT_ASSERT( t.find( v5 ));
+ CPPUNIT_ASSERT( t.contains( v5.nKey ));
+ CPPUNIT_ASSERT( t.contains( v5 ));
CPPUNIT_ASSERT( !t.empty() );
CPPUNIT_ASSERT( misc::check_size( t, 1 ));
CPPUNIT_ASSERT( t.erase_with( v5.nKey, less<value_type>(), erase_functor() ));
CPPUNIT_ASSERT( t.check_consistency() );
CPPUNIT_ASSERT( v5.stat.nEraseFuncCall == 1 );
- CPPUNIT_ASSERT( !t.find( v1.nKey ));
- CPPUNIT_ASSERT( !t.find( v1 ));
- CPPUNIT_ASSERT( !t.find( v2.nKey ));
- CPPUNIT_ASSERT( !t.find( v2 ));
- CPPUNIT_ASSERT( !t.find( v3.nKey ));
- CPPUNIT_ASSERT( !t.find( v3 ));
+ CPPUNIT_ASSERT( !t.contains( v1.nKey ));
+ CPPUNIT_ASSERT( !t.contains( v1 ));
+ CPPUNIT_ASSERT( !t.contains( v2.nKey ));
+ CPPUNIT_ASSERT( !t.contains( v2 ));
+ CPPUNIT_ASSERT( !t.contains( v3.nKey ));
+ CPPUNIT_ASSERT( !t.contains( v3 ));
CPPUNIT_ASSERT( !t.erase_with(v5, less<value_type>(), erase_functor() ));
- CPPUNIT_ASSERT( !t.find( v4.nKey ));
- CPPUNIT_ASSERT( !t.find( v4 ));
- CPPUNIT_ASSERT( !t.find( v5.nKey ));
- CPPUNIT_ASSERT( !t.find( v5 ));
+ CPPUNIT_ASSERT( !t.contains( v4.nKey ));
+ CPPUNIT_ASSERT( !t.contains( v4 ));
+ CPPUNIT_ASSERT( !t.contains( v5.nKey ));
+ CPPUNIT_ASSERT( !t.contains( v5 ));
CPPUNIT_ASSERT( t.empty() );
CPPUNIT_ASSERT( misc::check_size( t, 0 ));
tree_type::gc::force_dispose();
- // find
+ // contains
CPPUNIT_ASSERT( t.insert( v1 ));
CPPUNIT_ASSERT( t.insert( v2 ));
CPPUNIT_ASSERT( t.insert( v3 ));
CPPUNIT_ASSERT( !t.empty() );
CPPUNIT_ASSERT( misc::check_size( t, 5 ));
- CPPUNIT_ASSERT( t.find( 10 ));
- CPPUNIT_ASSERT( !t.find( 11 ));
- CPPUNIT_ASSERT( t.find( v1 ));
- CPPUNIT_ASSERT( t.find( v2.nKey ));
- CPPUNIT_ASSERT( t.find( v3 ));
- CPPUNIT_ASSERT( t.find( v4.nKey ));
- CPPUNIT_ASSERT( t.find( v5.nKey ));
-
- // find_with
- CPPUNIT_ASSERT( t.find_with( 10, less<value_type>() ));
- CPPUNIT_ASSERT( !t.find_with( wrapped_int(11), wrapped_less<value_type>() ));
- CPPUNIT_ASSERT( t.find_with( v1, less<value_type>() ));
- CPPUNIT_ASSERT( t.find_with( wrapped_int(v2.nKey), wrapped_less<value_type>() ));
- CPPUNIT_ASSERT( t.find_with( v3, less<value_type>() ));
- CPPUNIT_ASSERT( t.find_with( v4.nKey, less<value_type>() ));
- CPPUNIT_ASSERT( t.find_with( v5.nKey, less<value_type>() ));
+ CPPUNIT_ASSERT( t.contains( 10 ));
+ CPPUNIT_ASSERT( !t.contains( 11 ));
+ CPPUNIT_ASSERT( t.contains( v1 ));
+ CPPUNIT_ASSERT( t.contains( v2.nKey ));
+ CPPUNIT_ASSERT( t.contains( v3 ));
+ CPPUNIT_ASSERT( t.contains( v4.nKey ));
+ CPPUNIT_ASSERT( t.contains( v5.nKey ));
+
+ // contains
+ CPPUNIT_ASSERT( t.contains( 10, less<value_type>() ));
+ CPPUNIT_ASSERT( !t.contains( wrapped_int(11), wrapped_less<value_type>() ));
+ CPPUNIT_ASSERT( t.contains( v1, less<value_type>() ));
+ CPPUNIT_ASSERT( t.contains( wrapped_int(v2.nKey), wrapped_less<value_type>() ));
+ CPPUNIT_ASSERT( t.contains( v3, less<value_type>() ));
+ CPPUNIT_ASSERT( t.contains( v4.nKey, less<value_type>() ));
+ CPPUNIT_ASSERT( t.contains( v5.nKey, less<value_type>() ));
// find<Func>
CPPUNIT_ASSERT( v1.stat.nFindFuncCall == 0 );
CPPUNIT_ASSERT( t.check_consistency() );
for ( int n = 0; n < (int) c_nItemCount; ++n ) {
- CPPUNIT_ASSERT_MSG( t.find( n ), n );
+ CPPUNIT_ASSERT_MSG( t.contains( n ), n );
}
for ( value_type * p = pFirst; p != pLast; ++p ) {
- CPPUNIT_ASSERT( t.find( *p ));
- CPPUNIT_ASSERT( t.find( p->nKey ));
+ CPPUNIT_ASSERT( t.contains( *p ));
+ CPPUNIT_ASSERT( t.contains( p->nKey ));
CPPUNIT_ASSERT( t.unlink( *p ) );
CPPUNIT_ASSERT( !t.unlink( *p ) );
- CPPUNIT_ASSERT( !t.find( p->nKey ));
+ CPPUNIT_ASSERT( !t.contains( p->nKey ));
}
tree_type::gc::force_dispose();
value_type * pLast = arr.end();
for ( value_type * p = pFirst; p != pLast; ++p ) {
- CPPUNIT_ASSERT( t.ensure( *p, ensure_functor()).second );
+ CPPUNIT_ASSERT( t.update( *p, update_functor()).second );
}
for ( int n = 0; n < (int) c_nItemCount; ++n ) {
typename tree_type::guarded_ptr gp( t.extract_min() );