{
unsigned int nDisposeCount ; // count of disposer calling
unsigned int nFindCount ; // count of find-functor calling
- unsigned int nEnsureNewCount;
- unsigned int nEnsureCount;
+ unsigned int nUpdateNewCount;
+ unsigned int nUpdateCount;
mutable unsigned int nEraseCount;
stat()
}
};
- struct ensure_functor
+ struct update_functor
{
template <typename Item>
void operator()( bool bNew, Item& item, Item& /*val*/ )
{
if ( bNew )
- ++item.nEnsureNewCount;
+ ++item.nUpdateNewCount;
else
- ++item.nEnsureCount;
+ ++item.nUpdateCount;
}
};
CPPUNIT_ASSERT( check_size( s, 0 ));
// insert/find test
- CPPUNIT_ASSERT( !s.find( v1.key() ));
+ CPPUNIT_ASSERT( !s.contains( v1.key() ));
CPPUNIT_ASSERT( s.insert( v1 ));
- CPPUNIT_ASSERT( s.find( v1.key() ));
+ CPPUNIT_ASSERT( s.contains( v1.key() ));
CPPUNIT_ASSERT( check_size( s, 1 ));
CPPUNIT_ASSERT( !s.empty() );
- CPPUNIT_ASSERT( !s.find_with( v2.key(), less<value_type>() ));
+ CPPUNIT_ASSERT( !s.contains( v2.key(), less<value_type>() ));
CPPUNIT_ASSERT( s.insert( v2 ));
CPPUNIT_ASSERT( v2.nFindCount == 0 );
CPPUNIT_ASSERT( s.find_with( key = v2.key(), less<value_type>(), find_functor() ));
{
insert_functor fi;
find_functor ff;
- CPPUNIT_ASSERT( !s.find( v3 ));
+ CPPUNIT_ASSERT( !s.contains( v3 ));
CPPUNIT_ASSERT( v3.nVal != v3.nKey * 100 );
CPPUNIT_ASSERT( s.insert( v3, std::ref(fi) ));
CPPUNIT_ASSERT( v3.nVal == v3.nKey * 100 );
// unlink test
CPPUNIT_ASSERT( s.unlink( v1 ));
- CPPUNIT_ASSERT( !s.find( v1 ));
- CPPUNIT_ASSERT( s.find( v2 ));
- CPPUNIT_ASSERT( s.find( v3 ));
+ CPPUNIT_ASSERT( !s.contains( v1 ));
+ CPPUNIT_ASSERT( s.contains( v2 ));
+ CPPUNIT_ASSERT( s.contains( v3 ));
CPPUNIT_ASSERT( check_size( s, 2 ));
CPPUNIT_ASSERT( !s.unlink( v1 ));
- CPPUNIT_ASSERT( !s.find( v1 ));
+ CPPUNIT_ASSERT( !s.contains( v1 ));
CPPUNIT_ASSERT( check_size( s, 2 ));
- CPPUNIT_ASSERT( s.find_with( v3, less<value_type>() ));
+ CPPUNIT_ASSERT( s.contains( v3, less<value_type>() ));
CPPUNIT_ASSERT( s.unlink( v3 ));
- CPPUNIT_ASSERT( !s.find_with( v3, less<value_type>() ));
+ CPPUNIT_ASSERT( !s.contains( v3, less<value_type>() ));
CPPUNIT_ASSERT( check_size( s, 1 ));
- CPPUNIT_ASSERT( s.find( v2 ));
+ CPPUNIT_ASSERT( s.contains( v2 ));
CPPUNIT_ASSERT( s.unlink( v2 ));
- CPPUNIT_ASSERT( !s.find( v1 ));
- CPPUNIT_ASSERT( !s.find( v2 ));
- CPPUNIT_ASSERT( !s.find( v3 ));
+ CPPUNIT_ASSERT( !s.contains( v1 ));
+ CPPUNIT_ASSERT( !s.contains( v2 ));
+ CPPUNIT_ASSERT( !s.contains( v3 ));
CPPUNIT_ASSERT( check_size( s, 0 ));
CPPUNIT_ASSERT( s.empty() );
CPPUNIT_ASSERT( v2.nDisposeCount == 1 );
CPPUNIT_ASSERT( v3.nDisposeCount == 1 );
- // ensure test
+ // update test
{
- ensure_functor f;
- std::pair<bool, bool> ret = s.ensure( v1, f );
+ update_functor f;
+ std::pair<bool, bool> ret = s.update(v1, f, false);
+ CPPUNIT_ASSERT(!ret.first);
+ CPPUNIT_ASSERT(!ret.second);
+ CPPUNIT_ASSERT(v1.nUpdateNewCount == 0);
+ CPPUNIT_ASSERT(v1.nUpdateCount == 0);
+ CPPUNIT_ASSERT(check_size(s, 0));
+
+ ret = s.update( v1, f );
CPPUNIT_ASSERT( ret.first );
CPPUNIT_ASSERT( ret.second );
- CPPUNIT_ASSERT( v1.nEnsureNewCount == 1 );
- CPPUNIT_ASSERT( v1.nEnsureCount == 0 );
+ CPPUNIT_ASSERT( v1.nUpdateNewCount == 1 );
+ CPPUNIT_ASSERT( v1.nUpdateCount == 0 );
CPPUNIT_ASSERT( check_size( s, 1 ));
- ret = s.ensure( v2, f );
+ ret = s.update(v1, f, false);
+ CPPUNIT_ASSERT(ret.first);
+ CPPUNIT_ASSERT(!ret.second);
+ CPPUNIT_ASSERT(v1.nUpdateNewCount == 1);
+ CPPUNIT_ASSERT(v1.nUpdateCount == 1);
+ CPPUNIT_ASSERT(check_size(s, 1));
+
+ ret = s.update( v2, f );
CPPUNIT_ASSERT( ret.first );
CPPUNIT_ASSERT( ret.second );
- CPPUNIT_ASSERT( v2.nEnsureNewCount == 1 );
- CPPUNIT_ASSERT( v2.nEnsureCount == 0 );
+ CPPUNIT_ASSERT( v2.nUpdateNewCount == 1 );
+ CPPUNIT_ASSERT( v2.nUpdateCount == 0 );
CPPUNIT_ASSERT( check_size( s, 2 ));
- ret = s.ensure( v3, f );
+ ret = s.update( v3, f );
CPPUNIT_ASSERT( ret.first );
CPPUNIT_ASSERT( ret.second );
- CPPUNIT_ASSERT( v3.nEnsureNewCount == 1 );
- CPPUNIT_ASSERT( v3.nEnsureCount == 0 );
+ CPPUNIT_ASSERT( v3.nUpdateNewCount == 1 );
+ CPPUNIT_ASSERT( v3.nUpdateCount == 0 );
CPPUNIT_ASSERT( check_size( s, 3 ));
- CPPUNIT_ASSERT( s.find( v1 ));
- CPPUNIT_ASSERT( s.find( v2 ));
- CPPUNIT_ASSERT( s.find( v3 ));
+ CPPUNIT_ASSERT( s.contains( v1 ));
+ CPPUNIT_ASSERT( s.contains( v2 ));
+ CPPUNIT_ASSERT( s.contains( v3 ));
- ret = s.ensure( v1, f );
+ ret = s.update( v1, f );
CPPUNIT_ASSERT( ret.first );
CPPUNIT_ASSERT( !ret.second );
- CPPUNIT_ASSERT( v1.nEnsureNewCount == 1 );
- CPPUNIT_ASSERT( v1.nEnsureCount == 1 );
+ CPPUNIT_ASSERT( v1.nUpdateNewCount == 1 );
+ CPPUNIT_ASSERT( v1.nUpdateCount == 1 );
CPPUNIT_ASSERT( check_size( s, 3 ));
- ret = s.ensure( v2, f );
+ ret = s.update( v2, f );
CPPUNIT_ASSERT( ret.first );
CPPUNIT_ASSERT( !ret.second );
- CPPUNIT_ASSERT( v2.nEnsureNewCount == 1 );
- CPPUNIT_ASSERT( v2.nEnsureCount == 1 );
+ CPPUNIT_ASSERT( v2.nUpdateNewCount == 1 );
+ CPPUNIT_ASSERT( v2.nUpdateCount == 1 );
CPPUNIT_ASSERT( check_size( s, 3 ));
- ret = s.ensure( v3, f );
+ ret = s.update( v3, f );
CPPUNIT_ASSERT( ret.first );
CPPUNIT_ASSERT( !ret.second );
- CPPUNIT_ASSERT( v3.nEnsureNewCount == 1 );
- CPPUNIT_ASSERT( v3.nEnsureCount == 1 );
+ CPPUNIT_ASSERT( v3.nUpdateNewCount == 1 );
+ CPPUNIT_ASSERT( v3.nUpdateCount == 1 );
CPPUNIT_ASSERT( check_size( s, 3 ));
- CPPUNIT_ASSERT( s.find( v1 ));
- CPPUNIT_ASSERT( s.find( v2 ));
- CPPUNIT_ASSERT( s.find( v3 ));
+ CPPUNIT_ASSERT( s.contains( v1 ));
+ CPPUNIT_ASSERT( s.contains( v2 ));
+ CPPUNIT_ASSERT( s.contains( v3 ));
}
// erase test
- CPPUNIT_ASSERT( s.find( v1 ));
- CPPUNIT_ASSERT( s.find_with( v2, less<value_type>() ));
- CPPUNIT_ASSERT( s.find( v3 ));
+ CPPUNIT_ASSERT( s.contains( v1 ));
+ CPPUNIT_ASSERT( s.contains( v2, less<value_type>() ));
+ CPPUNIT_ASSERT( s.contains( v3 ));
CPPUNIT_ASSERT( check_size( s, 3 ));
CPPUNIT_ASSERT( !s.empty() );
CPPUNIT_ASSERT( s.erase( v1 ));
- CPPUNIT_ASSERT( !s.find( v1 ));
- CPPUNIT_ASSERT( s.find( v2 ));
- CPPUNIT_ASSERT( s.find( v3 ));
+ CPPUNIT_ASSERT( !s.contains( v1 ));
+ CPPUNIT_ASSERT( s.contains( v2 ));
+ CPPUNIT_ASSERT( s.contains( v3 ));
CPPUNIT_ASSERT( check_size( s, 2 ));
CPPUNIT_ASSERT( !s.empty() );
CPPUNIT_ASSERT( v1.nEraseCount == 0 );
CPPUNIT_ASSERT( !s.erase( v1, erase_functor() ));
CPPUNIT_ASSERT( v1.nEraseCount == 0 );
- CPPUNIT_ASSERT( !s.find( v1 ));
- CPPUNIT_ASSERT( s.find( v2 ));
- CPPUNIT_ASSERT( s.find( v3 ));
+ CPPUNIT_ASSERT( !s.contains( v1 ));
+ CPPUNIT_ASSERT( s.contains( v2 ));
+ CPPUNIT_ASSERT( s.contains( v3 ));
CPPUNIT_ASSERT( check_size( s, 2 ));
CPPUNIT_ASSERT( !s.empty() );
CPPUNIT_ASSERT( v2.nEraseCount == 0 );
CPPUNIT_ASSERT( s.erase_with( v2.key(), less<value_type>(), erase_functor() ));
CPPUNIT_ASSERT( v2.nEraseCount == 1 );
- CPPUNIT_ASSERT( !s.find( v1 ));
- CPPUNIT_ASSERT( !s.find( v2 ));
- CPPUNIT_ASSERT( s.find( v3 ));
+ CPPUNIT_ASSERT( !s.contains( v1 ));
+ CPPUNIT_ASSERT( !s.contains( v2 ));
+ CPPUNIT_ASSERT( s.contains( v3 ));
CPPUNIT_ASSERT( check_size( s, 1 ));
CPPUNIT_ASSERT( !s.empty() );
CPPUNIT_ASSERT( !s.erase( v2.key() ));
- CPPUNIT_ASSERT( !s.find( v1 ));
- CPPUNIT_ASSERT( !s.find( v2 ));
- CPPUNIT_ASSERT( s.find( v3 ));
+ CPPUNIT_ASSERT( !s.contains( v1 ));
+ CPPUNIT_ASSERT( !s.contains( v2 ));
+ CPPUNIT_ASSERT( s.contains( v3 ));
CPPUNIT_ASSERT( check_size( s, 1 ));
CPPUNIT_ASSERT( !s.empty() );
CPPUNIT_ASSERT( s.erase( v3 ));
- CPPUNIT_ASSERT( !s.find( v1 ));
- CPPUNIT_ASSERT( !s.find( v2 ));
- CPPUNIT_ASSERT( !s.find( v3 ));
+ CPPUNIT_ASSERT( !s.contains( v1 ));
+ CPPUNIT_ASSERT( !s.contains( v2 ));
+ CPPUNIT_ASSERT( !s.contains( v3 ));
CPPUNIT_ASSERT( check_size( s, 0 ));
CPPUNIT_ASSERT( s.empty() );
}
CPPUNIT_ASSERT( s.unlink( v3 ) );
- CPPUNIT_ASSERT( s.find( v1 ));
- CPPUNIT_ASSERT( !s.find( v2 ));
- CPPUNIT_ASSERT( !s.find( v3 ));
+ CPPUNIT_ASSERT( s.contains( v1 ));
+ CPPUNIT_ASSERT( !s.contains( v2 ));
+ CPPUNIT_ASSERT( !s.contains( v3 ));
CPPUNIT_ASSERT( check_size( s, 1 ));
CPPUNIT_ASSERT( !s.empty() );
CPPUNIT_ASSERT( !s.unlink( v3 ));
- CPPUNIT_ASSERT( s.find( v1 ));
- CPPUNIT_ASSERT( !s.find( v2 ));
- CPPUNIT_ASSERT( !s.find( v3 ));
+ CPPUNIT_ASSERT( s.contains( v1 ));
+ CPPUNIT_ASSERT( !s.contains( v2 ));
+ CPPUNIT_ASSERT( !s.contains( v3 ));
CPPUNIT_ASSERT( check_size( s, 1 ));
CPPUNIT_ASSERT( !s.empty() );
CPPUNIT_ASSERT( s.unlink( v1 ));
- CPPUNIT_ASSERT( !s.find( v1 ));
- CPPUNIT_ASSERT( !s.find( v2 ));
- CPPUNIT_ASSERT( !s.find( v3 ));
+ CPPUNIT_ASSERT( !s.contains( v1 ));
+ CPPUNIT_ASSERT( !s.contains( v2 ));
+ CPPUNIT_ASSERT( !s.contains( v3 ));
CPPUNIT_ASSERT( check_size( s, 0 ));
CPPUNIT_ASSERT( s.empty() );
CPPUNIT_ASSERT( !s.unlink( v2 ));
- CPPUNIT_ASSERT( !s.find( v1 ));
- CPPUNIT_ASSERT( !s.find( v2 ));
- CPPUNIT_ASSERT( !s.find( v3 ));
+ CPPUNIT_ASSERT( !s.contains( v1 ));
+ CPPUNIT_ASSERT( !s.contains( v2 ));
+ CPPUNIT_ASSERT( !s.contains( v3 ));
CPPUNIT_ASSERT( check_size( s, 0 ));
CPPUNIT_ASSERT( s.empty() );
CPPUNIT_ASSERT( check_size( s, 0 ));
// insert/find test
- CPPUNIT_ASSERT( s.find( v1.key() ) == nullptr );
+ CPPUNIT_ASSERT( s.contains( v1.key() ) == nullptr );
CPPUNIT_ASSERT( s.insert( v1 ));
- CPPUNIT_ASSERT( s.find_with( v1.key(), less<value_type>() ) == &v1 );
+ CPPUNIT_ASSERT( s.contains( v1.key(), less<value_type>() ) == &v1 );
CPPUNIT_ASSERT( check_size( s, 1 ));
CPPUNIT_ASSERT( !s.empty() );
- CPPUNIT_ASSERT( s.find( v2.key() ) == nullptr );
+ CPPUNIT_ASSERT( s.contains( v2.key() ) == nullptr );
CPPUNIT_ASSERT( s.insert( v2 ));
CPPUNIT_ASSERT( v2.nFindCount == 0 );
CPPUNIT_ASSERT( s.find( key = v2.key(), find_functor() ));
{
find_functor ff;
- CPPUNIT_ASSERT( s.find( v3 ) == nullptr );
+ CPPUNIT_ASSERT( s.contains( v3 ) == nullptr );
CPPUNIT_ASSERT( s.insert( v3 ));
CPPUNIT_ASSERT( v3.nFindCount == 0 );
CPPUNIT_ASSERT( s.find_with( v3, less<value_type>(), std::ref(ff) ));
CPPUNIT_ASSERT( v3.nDisposeCount == 1 );
- // ensure test
+ // update test
{
Set s( 64, 4 );
- ensure_functor f;
- std::pair<bool, bool> ret = s.ensure( v1, f );
+ update_functor f;
+
+ std::pair<bool, bool> ret = s.update(v1, f, false);
+ CPPUNIT_ASSERT(!ret.first);
+ CPPUNIT_ASSERT(!ret.second);
+ CPPUNIT_ASSERT(v1.nUpdateNewCount == 0);
+ CPPUNIT_ASSERT(v1.nUpdateCount == 0);
+ CPPUNIT_ASSERT(check_size(s, 0));
+
+ ret = s.update( v1, f );
CPPUNIT_ASSERT( ret.first );
CPPUNIT_ASSERT( ret.second );
- CPPUNIT_ASSERT( v1.nEnsureNewCount == 1 );
- CPPUNIT_ASSERT( v1.nEnsureCount == 0 );
+ CPPUNIT_ASSERT( v1.nUpdateNewCount == 1 );
+ CPPUNIT_ASSERT( v1.nUpdateCount == 0 );
CPPUNIT_ASSERT( check_size( s, 1 ));
- ret = s.ensure( v2, f );
+ ret = s.update(v1, f, false);
+ CPPUNIT_ASSERT(ret.first);
+ CPPUNIT_ASSERT(!ret.second);
+ CPPUNIT_ASSERT(v1.nUpdateNewCount == 1);
+ CPPUNIT_ASSERT(v1.nUpdateCount == 1);
+ CPPUNIT_ASSERT(check_size(s, 1));
+
+ ret = s.update( v2, f );
CPPUNIT_ASSERT( ret.first );
CPPUNIT_ASSERT( ret.second );
- CPPUNIT_ASSERT( v2.nEnsureNewCount == 1 );
- CPPUNIT_ASSERT( v2.nEnsureCount == 0 );
+ CPPUNIT_ASSERT( v2.nUpdateNewCount == 1 );
+ CPPUNIT_ASSERT( v2.nUpdateCount == 0 );
CPPUNIT_ASSERT( check_size( s, 2 ));
- ret = s.ensure( v3, f );
+ ret = s.update( v3, f );
CPPUNIT_ASSERT( ret.first );
CPPUNIT_ASSERT( ret.second );
- CPPUNIT_ASSERT( v3.nEnsureNewCount == 1 );
- CPPUNIT_ASSERT( v3.nEnsureCount == 0 );
+ CPPUNIT_ASSERT( v3.nUpdateNewCount == 1 );
+ CPPUNIT_ASSERT( v3.nUpdateCount == 0 );
CPPUNIT_ASSERT( check_size( s, 3 ));
- CPPUNIT_ASSERT( s.find( v1 ) == &v1 );
- CPPUNIT_ASSERT( s.find( v2 ) == &v2 );
- CPPUNIT_ASSERT( s.find( v3 ) == &v3 );
+ CPPUNIT_ASSERT( s.contains( v1 ) == &v1 );
+ CPPUNIT_ASSERT( s.contains( v2 ) == &v2 );
+ CPPUNIT_ASSERT( s.contains( v3 ) == &v3 );
- ret = s.ensure( v1, f );
+ ret = s.update( v1, f );
CPPUNIT_ASSERT( ret.first );
CPPUNIT_ASSERT( !ret.second );
- CPPUNIT_ASSERT( v1.nEnsureNewCount == 1 );
- CPPUNIT_ASSERT( v1.nEnsureCount == 1 );
+ CPPUNIT_ASSERT( v1.nUpdateNewCount == 1 );
+ CPPUNIT_ASSERT( v1.nUpdateCount == 1 );
CPPUNIT_ASSERT( check_size( s, 3 ));
- ret = s.ensure( v2, f );
+ ret = s.update( v2, f );
CPPUNIT_ASSERT( ret.first );
CPPUNIT_ASSERT( !ret.second );
- CPPUNIT_ASSERT( v2.nEnsureNewCount == 1 );
- CPPUNIT_ASSERT( v2.nEnsureCount == 1 );
+ CPPUNIT_ASSERT( v2.nUpdateNewCount == 1 );
+ CPPUNIT_ASSERT( v2.nUpdateCount == 1 );
CPPUNIT_ASSERT( check_size( s, 3 ));
- ret = s.ensure( v3, f );
+ ret = s.update( v3, f );
CPPUNIT_ASSERT( ret.first );
CPPUNIT_ASSERT( !ret.second );
- CPPUNIT_ASSERT( v3.nEnsureNewCount == 1 );
- CPPUNIT_ASSERT( v3.nEnsureCount == 1 );
+ CPPUNIT_ASSERT( v3.nUpdateNewCount == 1 );
+ CPPUNIT_ASSERT( v3.nUpdateCount == 1 );
CPPUNIT_ASSERT( check_size( s, 3 ));
- CPPUNIT_ASSERT( s.find( v1 ) == &v1 );
- CPPUNIT_ASSERT( s.find( v2 ) == &v2 );
- CPPUNIT_ASSERT( s.find( v3 ) == &v3 );
+ CPPUNIT_ASSERT( s.contains( v1 ) == &v1 );
+ CPPUNIT_ASSERT( s.contains( v2 ) == &v2 );
+ CPPUNIT_ASSERT( s.contains( v3 ) == &v3 );
}
}
// insert/find test
- ASSERT_RCU_FIND( !s.find_with( v1.key(), less<value_type>() ));
+ ASSERT_RCU_FIND( !s.contains( v1.key(), less<value_type>() ));
CPPUNIT_ASSERT( s.insert( v1 ));
- ASSERT_RCU_FIND( s.find_with( v1.key(), less<value_type>()) );
+ ASSERT_RCU_FIND( s.contains( v1.key(), less<value_type>()) );
CPPUNIT_ASSERT( check_size( s, 1 ));
CPPUNIT_ASSERT( !s.empty() );
- ASSERT_RCU_FIND( !s.find( v2.key() ));
+ ASSERT_RCU_FIND( !s.contains( v2.key() ));
CPPUNIT_ASSERT( s.insert( v2 ));
CPPUNIT_ASSERT( v2.nFindCount == 0 );
CPPUNIT_ASSERT( s.find( key = v2.key(), find_functor() ));
{
insert_functor fi;
find_functor ff;
- ASSERT_RCU_FIND( !s.find( v3 ));
+ ASSERT_RCU_FIND( !s.contains( v3 ));
CPPUNIT_ASSERT( v3.nVal != v3.nKey * 100 );
CPPUNIT_ASSERT( s.insert( v3, std::ref(fi) ));
CPPUNIT_ASSERT( v3.nVal == v3.nKey * 100 );
// unlink test
CPPUNIT_ASSERT( s.unlink( v1 ));
- ASSERT_RCU_FIND( !s.find( v1 ));
- ASSERT_RCU_FIND( s.find( v2 ));
- ASSERT_RCU_FIND( s.find( v3 ));
+ ASSERT_RCU_FIND( !s.contains( v1 ));
+ ASSERT_RCU_FIND( s.contains( v2 ));
+ ASSERT_RCU_FIND( s.contains( v3 ));
CPPUNIT_ASSERT( check_size( s, 2 ));
CPPUNIT_ASSERT( !s.unlink( v1 ));
- ASSERT_RCU_FIND( !s.find( v1 ));
+ ASSERT_RCU_FIND( !s.contains( v1 ));
CPPUNIT_ASSERT( check_size( s, 2 ));
- ASSERT_RCU_FIND( s.find( v3 ) );
+ ASSERT_RCU_FIND( s.contains( v3 ) );
CPPUNIT_ASSERT( s.unlink( v3 ));
- ASSERT_RCU_FIND( !s.find( v3 ));
+ ASSERT_RCU_FIND( !s.contains( v3 ));
CPPUNIT_ASSERT( check_size( s, 1 ));
- ASSERT_RCU_FIND( s.find( v2 ));
+ ASSERT_RCU_FIND( s.contains( v2 ));
CPPUNIT_ASSERT( s.unlink( v2 ));
- ASSERT_RCU_FIND( !s.find( v1 ));
- ASSERT_RCU_FIND( !s.find( v2 ));
- ASSERT_RCU_FIND( !s.find( v3 ));
+ ASSERT_RCU_FIND( !s.contains( v1 ));
+ ASSERT_RCU_FIND( !s.contains( v2 ));
+ ASSERT_RCU_FIND( !s.contains( v3 ));
CPPUNIT_ASSERT( check_size( s, 0 ));
CPPUNIT_ASSERT( s.empty() );
CPPUNIT_ASSERT( v2.nDisposeCount == 1 );
CPPUNIT_ASSERT( v3.nDisposeCount == 1 );
- // ensure test
+ // update test
{
- ensure_functor f;
- std::pair<bool, bool> ret = s.ensure( v1, f );
+ update_functor f;
+
+ std::pair<bool, bool> ret = s.update(v1, f, false);
+ CPPUNIT_ASSERT(!ret.first);
+ CPPUNIT_ASSERT(!ret.second);
+ CPPUNIT_ASSERT(v1.nUpdateNewCount == 0);
+ CPPUNIT_ASSERT(v1.nUpdateCount == 0);
+ CPPUNIT_ASSERT(check_size(s, 0));
+
+ ret = s.update( v1, f );
CPPUNIT_ASSERT( ret.first );
CPPUNIT_ASSERT( ret.second );
- CPPUNIT_ASSERT( v1.nEnsureNewCount == 1 );
- CPPUNIT_ASSERT( v1.nEnsureCount == 0 );
+ CPPUNIT_ASSERT( v1.nUpdateNewCount == 1 );
+ CPPUNIT_ASSERT( v1.nUpdateCount == 0 );
CPPUNIT_ASSERT( check_size( s, 1 ));
- ret = s.ensure( v2, f );
+ ret = s.update(v1, f, false);
+ CPPUNIT_ASSERT(ret.first);
+ CPPUNIT_ASSERT(!ret.second);
+ CPPUNIT_ASSERT(v1.nUpdateNewCount == 1);
+ CPPUNIT_ASSERT(v1.nUpdateCount == 1);
+ CPPUNIT_ASSERT(check_size(s, 1));
+
+ ret = s.update( v2, f );
CPPUNIT_ASSERT( ret.first );
CPPUNIT_ASSERT( ret.second );
- CPPUNIT_ASSERT( v2.nEnsureNewCount == 1 );
- CPPUNIT_ASSERT( v2.nEnsureCount == 0 );
+ CPPUNIT_ASSERT( v2.nUpdateNewCount == 1 );
+ CPPUNIT_ASSERT( v2.nUpdateCount == 0 );
CPPUNIT_ASSERT( check_size( s, 2 ));
- ret = s.ensure( v3, f );
+ ret = s.update( v3, f );
CPPUNIT_ASSERT( ret.first );
CPPUNIT_ASSERT( ret.second );
- CPPUNIT_ASSERT( v3.nEnsureNewCount == 1 );
- CPPUNIT_ASSERT( v3.nEnsureCount == 0 );
+ CPPUNIT_ASSERT( v3.nUpdateNewCount == 1 );
+ CPPUNIT_ASSERT( v3.nUpdateCount == 0 );
CPPUNIT_ASSERT( check_size( s, 3 ));
- ASSERT_RCU_FIND( s.find( v1 ));
- ASSERT_RCU_FIND( s.find( v2 ));
- ASSERT_RCU_FIND( s.find( v3 ));
+ ASSERT_RCU_FIND( s.contains( v1 ));
+ ASSERT_RCU_FIND( s.contains( v2 ));
+ ASSERT_RCU_FIND( s.contains( v3 ));
- ret = s.ensure( v1, f );
+ ret = s.update( v1, f );
CPPUNIT_ASSERT( ret.first );
CPPUNIT_ASSERT( !ret.second );
- CPPUNIT_ASSERT( v1.nEnsureNewCount == 1 );
- CPPUNIT_ASSERT( v1.nEnsureCount == 1 );
+ CPPUNIT_ASSERT( v1.nUpdateNewCount == 1 );
+ CPPUNIT_ASSERT( v1.nUpdateCount == 1 );
CPPUNIT_ASSERT( check_size( s, 3 ));
- ret = s.ensure( v2, f );
+ ret = s.update( v2, f );
CPPUNIT_ASSERT( ret.first );
CPPUNIT_ASSERT( !ret.second );
- CPPUNIT_ASSERT( v2.nEnsureNewCount == 1 );
- CPPUNIT_ASSERT( v2.nEnsureCount == 1 );
+ CPPUNIT_ASSERT( v2.nUpdateNewCount == 1 );
+ CPPUNIT_ASSERT( v2.nUpdateCount == 1 );
CPPUNIT_ASSERT( check_size( s, 3 ));
- ret = s.ensure( v3, f );
+ ret = s.update( v3, f );
CPPUNIT_ASSERT( ret.first );
CPPUNIT_ASSERT( !ret.second );
- CPPUNIT_ASSERT( v3.nEnsureNewCount == 1 );
- CPPUNIT_ASSERT( v3.nEnsureCount == 1 );
+ CPPUNIT_ASSERT( v3.nUpdateNewCount == 1 );
+ CPPUNIT_ASSERT( v3.nUpdateCount == 1 );
CPPUNIT_ASSERT( check_size( s, 3 ));
- ASSERT_RCU_FIND( s.find( v1 ) );
- ASSERT_RCU_FIND( s.find( v2 ));
- ASSERT_RCU_FIND( s.find( v3 ));
+ ASSERT_RCU_FIND( s.contains( v1 ) );
+ ASSERT_RCU_FIND( s.contains( v2 ));
+ ASSERT_RCU_FIND( s.contains( v3 ));
}
// erase test
- ASSERT_RCU_FIND( s.find( v1 ));
- ASSERT_RCU_FIND( s.find_with( v2, less<value_type>() ));
- ASSERT_RCU_FIND( s.find( v3 ));
+ ASSERT_RCU_FIND( s.contains( v1 ));
+ ASSERT_RCU_FIND( s.contains( v2, less<value_type>() ));
+ ASSERT_RCU_FIND( s.contains( v3 ));
CPPUNIT_ASSERT( check_size( s, 3 ));
CPPUNIT_ASSERT( !s.empty() );
CPPUNIT_ASSERT( v1.nEraseCount == 0 );
CPPUNIT_ASSERT( s.erase_with( v1, less<value_type>(), erase_functor() ));
CPPUNIT_ASSERT( v1.nEraseCount == 1 );
- ASSERT_RCU_FIND( !s.find( v1 ));
- ASSERT_RCU_FIND( s.find( v2 ) );
- ASSERT_RCU_FIND( s.find( v3 ) );
+ ASSERT_RCU_FIND( !s.contains( v1 ));
+ ASSERT_RCU_FIND( s.contains( v2 ) );
+ ASSERT_RCU_FIND( s.contains( v3 ) );
CPPUNIT_ASSERT( check_size( s, 2 ));
CPPUNIT_ASSERT( !s.empty() );
CPPUNIT_ASSERT( !s.erase( v1 ));
- ASSERT_RCU_FIND( !s.find( v1 ));
- ASSERT_RCU_FIND( s.find( v2 ));
- ASSERT_RCU_FIND( s.find( v3 ) );
+ ASSERT_RCU_FIND( !s.contains( v1 ));
+ ASSERT_RCU_FIND( s.contains( v2 ));
+ ASSERT_RCU_FIND( s.contains( v3 ) );
CPPUNIT_ASSERT( check_size( s, 2 ));
CPPUNIT_ASSERT( !s.empty() );
- ASSERT_RCU_FIND( !s.find( v4 ));
+ ASSERT_RCU_FIND( !s.contains( v4 ));
CPPUNIT_ASSERT( s.insert(v4));
- ASSERT_RCU_FIND( s.find( v4.key() ));
+ ASSERT_RCU_FIND( s.contains( v4.key() ));
CPPUNIT_ASSERT( s.erase_with( v4.key(), less<value_type>() ));
- ASSERT_RCU_FIND( !s.find( v4.key() ));
+ ASSERT_RCU_FIND( !s.contains( v4.key() ));
CPPUNIT_ASSERT( s.erase( v2.key() ));
- ASSERT_RCU_FIND( !s.find( v1 ));
- ASSERT_RCU_FIND( !s.find( v2 ));
- ASSERT_RCU_FIND( s.find( v3 ) );
+ ASSERT_RCU_FIND( !s.contains( v1 ));
+ ASSERT_RCU_FIND( !s.contains( v2 ));
+ ASSERT_RCU_FIND( s.contains( v3 ) );
CPPUNIT_ASSERT( check_size( s, 1 ));
CPPUNIT_ASSERT( !s.empty() );
CPPUNIT_ASSERT( !s.erase( v2.key() ));
- ASSERT_RCU_FIND( !s.find( v1 ));
- ASSERT_RCU_FIND( !s.find( v2 ));
- ASSERT_RCU_FIND( s.find( v3 ) );
+ ASSERT_RCU_FIND( !s.contains( v1 ));
+ ASSERT_RCU_FIND( !s.contains( v2 ));
+ ASSERT_RCU_FIND( s.contains( v3 ) );
CPPUNIT_ASSERT( check_size( s, 1 ));
CPPUNIT_ASSERT( !s.empty() );
CPPUNIT_ASSERT( v3.nEraseCount == 0 );
CPPUNIT_ASSERT( s.erase( v3, erase_functor() ));
CPPUNIT_ASSERT( v3.nEraseCount == 1 );
- ASSERT_RCU_FIND( !s.find( v1 ));
- ASSERT_RCU_FIND( !s.find( v2 ));
- ASSERT_RCU_FIND( !s.find( v3 ));
+ ASSERT_RCU_FIND( !s.contains( v1 ));
+ ASSERT_RCU_FIND( !s.contains( v2 ));
+ ASSERT_RCU_FIND( !s.contains( v3 ));
CPPUNIT_ASSERT( check_size( s, 0 ));
CPPUNIT_ASSERT( s.empty() );
}
CPPUNIT_ASSERT( s.unlink( v3 ) );
- ASSERT_RCU_FIND( s.find( v1 ));
- ASSERT_RCU_FIND( !s.find( v2 ));
- ASSERT_RCU_FIND( !s.find( v3 ));
+ ASSERT_RCU_FIND( s.contains( v1 ));
+ ASSERT_RCU_FIND( !s.contains( v2 ));
+ ASSERT_RCU_FIND( !s.contains( v3 ));
CPPUNIT_ASSERT( check_size( s, 1 ));
CPPUNIT_ASSERT( !s.empty() );
CPPUNIT_ASSERT( !s.unlink( v3 ));
- ASSERT_RCU_FIND( s.find( v1 ));
- ASSERT_RCU_FIND( !s.find( v2 ));
- ASSERT_RCU_FIND( !s.find( v3 ));
+ ASSERT_RCU_FIND( s.contains( v1 ));
+ ASSERT_RCU_FIND( !s.contains( v2 ));
+ ASSERT_RCU_FIND( !s.contains( v3 ));
CPPUNIT_ASSERT( check_size( s, 1 ));
CPPUNIT_ASSERT( !s.empty() );
CPPUNIT_ASSERT( s.unlink( v1 ));
- ASSERT_RCU_FIND( !s.find( v1 ));
- ASSERT_RCU_FIND( !s.find( v2 ));
- ASSERT_RCU_FIND( !s.find( v3 ));
+ ASSERT_RCU_FIND( !s.contains( v1 ));
+ ASSERT_RCU_FIND( !s.contains( v2 ));
+ ASSERT_RCU_FIND( !s.contains( v3 ));
CPPUNIT_ASSERT( check_size( s, 0 ));
CPPUNIT_ASSERT( s.empty() );
CPPUNIT_ASSERT( !s.unlink( v2 ));
- ASSERT_RCU_FIND( !s.find( v1 ));
- ASSERT_RCU_FIND( !s.find( v2 ));
- ASSERT_RCU_FIND( !s.find( v3 ));
+ ASSERT_RCU_FIND( !s.contains( v1 ));
+ ASSERT_RCU_FIND( !s.contains( v2 ));
+ ASSERT_RCU_FIND( !s.contains( v3 ));
CPPUNIT_ASSERT( check_size( s, 0 ));
CPPUNIT_ASSERT( s.empty() );
struct stat
{
unsigned int nFindCount ; // count of find-functor calling
- unsigned int nEnsureNewCount;
- unsigned int nEnsureCount;
+ unsigned int nUpdateNewCount;
+ unsigned int nUpdateCount;
stat()
{
void copy( stat const& s )
{
nFindCount = s.nFindCount;
- nEnsureCount = s.nEnsureCount;
- nEnsureNewCount = s.nEnsureNewCount;
+ nUpdateCount = s.nUpdateCount;
+ nUpdateNewCount = s.nUpdateNewCount;
}
};
};
template <typename Item, typename Q>
- static void ensure_func( bool bNew, Item& i, Q& /*val*/ )
+ static void udate_func( bool bNew, Item& i, Q& /*val*/ )
{
if ( bNew )
- ++i.nEnsureNewCount;
+ ++i.nUpdateNewCount;
else
- ++i.nEnsureCount;
+ ++i.nUpdateCount;
}
- struct ensure_functor
+ struct udate_functor
{
template <typename Item, typename Q>
void operator()( bool bNew, Item& i, Q& val )
{
- ensure_func( bNew, i, val );
+ udate_func( bNew, i, 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<value_type>() ) );
+ CPPUNIT_ASSERT( !s.contains( 20, less<value_type>() ) );
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<value_type>() ) );
- CPPUNIT_ASSERT( s.find( key = 20 ) );
+ CPPUNIT_ASSERT( s.contains( 10, less<value_type>() ) );
+ CPPUNIT_ASSERT( s.contains( key = 20 ) );
CPPUNIT_ASSERT( s.find_with( key, less<value_type>(), find_functor() ) );
{
copy_found<item> 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.nVal == 2500 );
}
- // ensure test
+ // update test
key = 10;
{
copy_found<item> f;
CPPUNIT_ASSERT( s.find( key, std::ref( f ) ) );
CPPUNIT_ASSERT( f.m_found.nKey == 10 );
CPPUNIT_ASSERT( f.m_found.nVal == 10 );
- CPPUNIT_ASSERT( f.m_found.nEnsureCount == 0 );
- CPPUNIT_ASSERT( f.m_found.nEnsureNewCount == 0 );
+ CPPUNIT_ASSERT( f.m_found.nUpdateCount == 0 );
+ CPPUNIT_ASSERT( f.m_found.nUpdateNewCount == 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, udate_functor() );
+ CPPUNIT_ASSERT( updateResult.first && !updateResult.second );
CPPUNIT_ASSERT( !s.empty() );
CPPUNIT_ASSERT( check_size( s, 3 ));
{
CPPUNIT_ASSERT( s.find( key, std::ref( f ) ) );
CPPUNIT_ASSERT( f.m_found.nKey == 10 );
CPPUNIT_ASSERT( f.m_found.nVal == 10 );
- CPPUNIT_ASSERT( f.m_found.nEnsureCount == 1 );
- CPPUNIT_ASSERT( f.m_found.nEnsureNewCount == 0 );
+ CPPUNIT_ASSERT( f.m_found.nUpdateCount == 1 );
+ CPPUNIT_ASSERT( f.m_found.nUpdateNewCount == 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), udate_functor(), false);
+ CPPUNIT_ASSERT(!updateResult.first && !updateResult.second);
+ CPPUNIT_ASSERT(check_size(s, 3));
+
+ updateResult = s.update( std::make_pair(13, 1300), udate_functor() );
+ CPPUNIT_ASSERT( updateResult.first && updateResult.second );
CPPUNIT_ASSERT( !s.empty() );
CPPUNIT_ASSERT( check_size( s, 4 ));
{
CPPUNIT_ASSERT( s.find( key, std::ref( f ) ) );
CPPUNIT_ASSERT( f.m_found.nKey == 13 );
CPPUNIT_ASSERT( f.m_found.nVal == 1300 );
- CPPUNIT_ASSERT( f.m_found.nEnsureCount == 0 );
- CPPUNIT_ASSERT( f.m_found.nEnsureNewCount == 1 );
+ CPPUNIT_ASSERT( f.m_found.nUpdateCount == 0 );
+ CPPUNIT_ASSERT( f.m_found.nUpdateNewCount == 1 );
}
// 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<value_type>() ));
- 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<value_type>()) );
CPPUNIT_ASSERT( !s.empty() );
CPPUNIT_ASSERT( check_size( s, 2 ));
- CPPUNIT_ASSERT( s.find(20) );
+ CPPUNIT_ASSERT( s.contains(20) );
{
copy_found<item> f;
CPPUNIT_ASSERT( s.erase( 20, std::ref( f ) ) );
CPPUNIT_ASSERT( f.m_found.nKey == 235 );
CPPUNIT_ASSERT( f.m_found.nVal == 235 );
}
- 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<value_type>()));
- CPPUNIT_ASSERT( s.find(190));
+ CPPUNIT_ASSERT( s.contains(151));
+ CPPUNIT_ASSERT( s.contains(174, less<value_type>()));
+ CPPUNIT_ASSERT( s.contains(190));
{
copy_found<item> f;
CPPUNIT_ASSERT( check_size( s, 2 ));
CPPUNIT_ASSERT( s.insert( 50 ) == s.end() );
- // ensure
- std::pair< iterator, bool> ensureResult;
- ensureResult = s.ensure( 20 );
- CPPUNIT_ASSERT( ensureResult.first != s.end() );
- CPPUNIT_ASSERT( ensureResult.second );
- CPPUNIT_ASSERT( ensureResult.first->key() == 20 );
- CPPUNIT_ASSERT( ensureResult.first->val() == 20 );
+ // update
+ std::pair< iterator, bool> updateResult;
+ updateResult = s.update(20, false);
+ CPPUNIT_ASSERT(updateResult.first == s.end());
+ CPPUNIT_ASSERT(!updateResult.second);
+ CPPUNIT_ASSERT(check_size(s, 2));
+
+ updateResult = s.update( 20 );
+ CPPUNIT_ASSERT( updateResult.first != s.end() );
+ CPPUNIT_ASSERT( updateResult.second );
+ CPPUNIT_ASSERT( updateResult.first->key() == 20 );
+ CPPUNIT_ASSERT( updateResult.first->val() == 20 );
CPPUNIT_ASSERT( !s.empty() );
CPPUNIT_ASSERT( check_size( s, 3 ));
- ensureResult = s.ensure( std::make_pair( 20, 200 ));
- CPPUNIT_ASSERT( ensureResult.first != s.end() );
- CPPUNIT_ASSERT( !ensureResult.second );
- CPPUNIT_ASSERT( ensureResult.first->key() == 20 );
- CPPUNIT_ASSERT( ensureResult.first->val() == 20 );
+ updateResult = s.update( std::make_pair( 20, 200 ));
+ CPPUNIT_ASSERT( updateResult.first != s.end() );
+ CPPUNIT_ASSERT( !updateResult.second );
+ CPPUNIT_ASSERT( updateResult.first->key() == 20 );
+ CPPUNIT_ASSERT( updateResult.first->val() == 20 );
CPPUNIT_ASSERT( !s.empty() );
CPPUNIT_ASSERT( check_size( s, 3 ));
- ensureResult.first->nVal = 22;
+ updateResult.first->nVal = 22;
- ensureResult = s.ensure( std::make_pair( 30, 33 ));
- CPPUNIT_ASSERT( ensureResult.first != s.end() );
- CPPUNIT_ASSERT( ensureResult.second );
- CPPUNIT_ASSERT( ensureResult.first->key() == 30 );
- CPPUNIT_ASSERT( ensureResult.first->val() == 33 );
+ updateResult = s.update( std::make_pair( 30, 33 ));
+ CPPUNIT_ASSERT( updateResult.first != s.end() );
+ CPPUNIT_ASSERT( updateResult.second );
+ CPPUNIT_ASSERT( updateResult.first->key() == 30 );
+ CPPUNIT_ASSERT( updateResult.first->val() == 33 );
CPPUNIT_ASSERT( !s.empty() );
CPPUNIT_ASSERT( check_size( s, 4 ));
// find
- it = s.find( 10 );
+ it = s.contains( 10 );
CPPUNIT_ASSERT( it != s.end() );
CPPUNIT_ASSERT( it->key() == 10 );
CPPUNIT_ASSERT( it->val() == 10 );
- it = s.find_with( 20, less<value_type>() );
+ it = s.contains( 20, less<value_type>() );
CPPUNIT_ASSERT( it != s.end() );
CPPUNIT_ASSERT( it->key() == 20 );
CPPUNIT_ASSERT( it->val() == 22 );
- it = s.find( 30 );
+ it = s.contains( 30 );
CPPUNIT_ASSERT( it != s.end() );
CPPUNIT_ASSERT( it->key() == 30 );
CPPUNIT_ASSERT( it->val() == 33 );
- it = s.find( 40 );
+ it = s.contains( 40 );
CPPUNIT_ASSERT( it == s.end() );
- it = s.find( 50 );
+ it = s.contains( 50 );
CPPUNIT_ASSERT( it != s.end() );
CPPUNIT_ASSERT( it->key() == 50 );
CPPUNIT_ASSERT( it->val() == 25 );
CPPUNIT_ASSERT( it->key() == 190 );
CPPUNIT_ASSERT( it->val() == 91 );
- it = s.find( 174 );
+ it = s.contains( 174 );
CPPUNIT_ASSERT( it != s.end() );
CPPUNIT_ASSERT( it->key() == 174 );
CPPUNIT_ASSERT( it->val() == 471 );
- it = s.find_with( 190, less<value_type>() );
+ it = s.contains( 190, less<value_type>() );
CPPUNIT_ASSERT( it != s.end() );
CPPUNIT_ASSERT( it->key() == 190 );
CPPUNIT_ASSERT( it->val() == 91 );
- it = s.find( 151 );
+ it = s.contains( 151 );
CPPUNIT_ASSERT( it != s.end() );
CPPUNIT_ASSERT( it->key() == 151 );
CPPUNIT_ASSERT( it->val() == 151 );
CPPUNIT_ASSERT( check_size( s, 2 ));
CPPUNIT_ASSERT( s.insert( 50 ) == s.end() );
- // ensure
- std::pair< iterator, bool> ensureResult;
- ensureResult = s.ensure( 20 );
- CPPUNIT_ASSERT( ensureResult.first != s.end() );
- CPPUNIT_ASSERT( ensureResult.second );
- CPPUNIT_ASSERT( ensureResult.first->key() == 20 );
- CPPUNIT_ASSERT( ensureResult.first->val() == 20 );
+ // update
+ std::pair< iterator, bool> updateResult;
+ updateResult = s.update(20, false);
+ CPPUNIT_ASSERT(updateResult.first == s.end());
+ CPPUNIT_ASSERT(!updateResult.second);
+ CPPUNIT_ASSERT(check_size(s, 2));
+
+ updateResult = s.update( 20 );
+ CPPUNIT_ASSERT( updateResult.first != s.end() );
+ CPPUNIT_ASSERT( updateResult.second );
+ CPPUNIT_ASSERT( updateResult.first->key() == 20 );
+ CPPUNIT_ASSERT( updateResult.first->val() == 20 );
CPPUNIT_ASSERT( !s.empty() );
CPPUNIT_ASSERT( check_size( s, 3 ));
- ensureResult = s.ensure( std::make_pair( 20, 200 ));
- CPPUNIT_ASSERT( ensureResult.first != s.end() );
- CPPUNIT_ASSERT( !ensureResult.second );
- CPPUNIT_ASSERT( ensureResult.first->key() == 20 );
- CPPUNIT_ASSERT( ensureResult.first->val() == 20 );
+ updateResult = s.update( std::make_pair( 20, 200 ));
+ CPPUNIT_ASSERT( updateResult.first != s.end() );
+ CPPUNIT_ASSERT( !updateResult.second );
+ CPPUNIT_ASSERT( updateResult.first->key() == 20 );
+ CPPUNIT_ASSERT( updateResult.first->val() == 20 );
CPPUNIT_ASSERT( !s.empty() );
CPPUNIT_ASSERT( check_size( s, 3 ));
- ensureResult.first->nVal = 22;
+ updateResult.first->nVal = 22;
- ensureResult = s.ensure( std::make_pair( 30, 33 ));
- CPPUNIT_ASSERT( ensureResult.first != s.end() );
- CPPUNIT_ASSERT( ensureResult.second );
- CPPUNIT_ASSERT( ensureResult.first->key() == 30 );
- CPPUNIT_ASSERT( ensureResult.first->val() == 33 );
+ updateResult = s.update( std::make_pair( 30, 33 ));
+ CPPUNIT_ASSERT( updateResult.first != s.end() );
+ CPPUNIT_ASSERT( updateResult.second );
+ CPPUNIT_ASSERT( updateResult.first->key() == 30 );
+ CPPUNIT_ASSERT( updateResult.first->val() == 33 );
CPPUNIT_ASSERT( !s.empty() );
CPPUNIT_ASSERT( check_size( s, 4 ));
// find
- it = s.find( 10 );
+ it = s.contains( 10 );
CPPUNIT_ASSERT( it != s.end() );
CPPUNIT_ASSERT( it->key() == 10 );
CPPUNIT_ASSERT( it->val() == 10 );
- it = s.find_with( 20, equal<value_type>() );
+ it = s.contains( 20, equal<value_type>() );
CPPUNIT_ASSERT( it != s.end() );
CPPUNIT_ASSERT( it->key() == 20 );
CPPUNIT_ASSERT( it->val() == 22 );
- it = s.find( 30 );
+ it = s.contains( 30 );
CPPUNIT_ASSERT( it != s.end() );
CPPUNIT_ASSERT( it->key() == 30 );
CPPUNIT_ASSERT( it->val() == 33 );
- it = s.find( 40 );
+ it = s.contains( 40 );
CPPUNIT_ASSERT( it == s.end() );
- it = s.find( 50 );
+ it = s.contains( 50 );
CPPUNIT_ASSERT( it != s.end() );
CPPUNIT_ASSERT( it->key() == 50 );
CPPUNIT_ASSERT( it->val() == 25 );
CPPUNIT_ASSERT( it->key() == 190 );
CPPUNIT_ASSERT( it->val() == 91 );
- it = s.find( 174 );
+ it = s.contains( 174 );
CPPUNIT_ASSERT( it != s.end() );
CPPUNIT_ASSERT( it->key() == 174 );
CPPUNIT_ASSERT( it->val() == 471 );
- it = s.find_with( 190, equal<value_type>() );
+ it = s.contains( 190, equal<value_type>() );
CPPUNIT_ASSERT( it != s.end() );
CPPUNIT_ASSERT( it->key() == 190 );
CPPUNIT_ASSERT( it->val() == 91 );
- it = s.find( 151 );
+ it = s.contains( 151 );
CPPUNIT_ASSERT( it != s.end() );
CPPUNIT_ASSERT( it->key() == 151 );
CPPUNIT_ASSERT( it->val() == 151 );