#if _MSC_VER == 1800
# define CDS_COMPILER__NAME "MS Visual C++ 2013"
# define CDS_COMPILER__NICK "vc12"
+# define CDS_COMPILER_LIBCDS_SUFFIX "vc12"
#elif _MSC_VER == 1900
# define CDS_COMPILER__NAME "MS Visual C++ 2015"
# define CDS_COMPILER__NICK "vc14"
+# define CDS_COMPILER_LIBCDS_SUFFIX "vcv140"
#else
# define CDS_COMPILER__NAME "MS Visual C++"
# define CDS_COMPILER__NICK "msvc"
+# define CDS_COMPILER_LIBCDS_SUFFIX "vc"
#endif
// OS interface
#endif
#if CDS_COMPILER == CDS_COMPILER_MSVC
-# pragma comment( lib, "libcds-" CDS_PROCESSOR__NICK "-" CDS_COMPILER__NICK CDS_LIB_DEBUG_SUFFIX )
+# pragma comment( lib, "libcds-" CDS_PROCESSOR__NICK "-" CDS_COMPILER_LIBCDS_SUFFIX CDS_LIB_DEBUG_SUFFIX )
#elif CDS_COMPILER == CDS_COMPILER_INTEL
-# pragma comment( lib, "libcds-" CDS_PROCESSOR__NICK "-" CDS_COMPILER__NICK CDS_LIB_DEBUG_SUFFIX )
+# pragma comment( lib, "libcds-" CDS_PROCESSOR__NICK "-" CDS_COMPILER_LIBCDS_SUFFIX CDS_LIB_DEBUG_SUFFIX )
#endif
#undef CDS_LIB_DEBUG_SUFFIX
<AdditionalOptions>/bigobj /Zc:inline %(AdditionalOptions)</AdditionalOptions>\r
<Optimization>Disabled</Optimization>\r
<AdditionalIncludeDirectories>$(SolutionDir)..\..\..;$(SolutionDir)..\..\..\tests\test-hdr;$(SolutionDir)..\..\..\tests;$(BOOST_PATH);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r
- <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_WIN32_WINNT=0x0500;_SCL_SECURE=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
+ <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_WIN32_WINNT=0x0500;_SCL_SECURE=0;%(PreprocessorDefinitions);_SCL_SECURE_NO_WARNINGS</PreprocessorDefinitions>\r
<MinimalRebuild>true</MinimalRebuild>\r
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>\r
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>\r
<AdditionalOptions>/bigobj /Zc:inline %(AdditionalOptions)</AdditionalOptions>\r
<Optimization>Disabled</Optimization>\r
<AdditionalIncludeDirectories>$(SolutionDir)..\..\..;$(SolutionDir)..\..\..\tests\test-hdr;$(SolutionDir)..\..\..\tests;$(BOOST_PATH);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r
- <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_WIN32_WINNT=0x0500;_SCL_SECURE=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
+ <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_WIN32_WINNT=0x0500;_SCL_SECURE=0;%(PreprocessorDefinitions);_SCL_SECURE_NO_WARNINGS</PreprocessorDefinitions>\r
<MinimalRebuild>true</MinimalRebuild>\r
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>\r
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>\r
<AdditionalOptions>/bigobj /Zc:inline %(AdditionalOptions)</AdditionalOptions>\r
<Optimization>Disabled</Optimization>\r
<AdditionalIncludeDirectories>$(SolutionDir)..\..\..;$(SolutionDir)..\..\..\tests\test-hdr;$(SolutionDir)..\..\..\tests;$(BOOST_PATH);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r
- <PreprocessorDefinitions>CDS_USE_VLD;WIN32;_DEBUG;_CONSOLE;_WIN32_WINNT=0x0500;_SCL_SECURE=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
+ <PreprocessorDefinitions>CDS_USE_VLD;WIN32;_DEBUG;_CONSOLE;_WIN32_WINNT=0x0500;_SCL_SECURE=0;%(PreprocessorDefinitions);_SCL_SECURE_NO_WARNINGS</PreprocessorDefinitions>\r
<MinimalRebuild>true</MinimalRebuild>\r
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>\r
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>\r
<AdditionalOptions>/bigobj /Zc:inline %(AdditionalOptions)</AdditionalOptions>\r
<Optimization>Disabled</Optimization>\r
<AdditionalIncludeDirectories>$(SolutionDir)..\..\..;$(SolutionDir)..\..\..\tests\test-hdr;$(SolutionDir)..\..\..\tests;$(BOOST_PATH);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r
- <PreprocessorDefinitions>CDS_USE_VLD;WIN32;_DEBUG;_CONSOLE;_WIN32_WINNT=0x0500;_SCL_SECURE=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
+ <PreprocessorDefinitions>CDS_USE_VLD;WIN32;_DEBUG;_CONSOLE;_WIN32_WINNT=0x0500;_SCL_SECURE=0;%(PreprocessorDefinitions);_SCL_SECURE_NO_WARNINGS</PreprocessorDefinitions>\r
<MinimalRebuild>true</MinimalRebuild>\r
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>\r
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>\r
};
typedef cc::CuckooSet< item, set_traits > set_t;
- // cc::cuckoo::make_traits<
- // co::equal_to< equal< item > >
- // ,co::hash< std::tuple< hash1, hash2 > >
- // >::type
- //> set_t;
test_int<set_t, equal< item > >();
}
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 update_func( bool bNew, Item& i, Q& /*val*/ )
{
if ( bNew )
- ++i.nEnsureNewCount;
+ ++i.nUpdateNewCount;
else
- ++i.nEnsureCount;
+ ++i.nUpdateCount;
}
- struct ensure_functor
+ struct update_functor
{
template <typename Item, typename Q>
void operator()( bool bNew, Item& i, Q& val )
{
- ensure_func( bNew, i, val );
+ update_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, pred ) );
+ CPPUNIT_ASSERT( !s.contains( 20, pred ) );
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, pred ) );
- CPPUNIT_ASSERT( s.find( key = 20 ) );
+ CPPUNIT_ASSERT( s.contains( 10, pred ) );
+ CPPUNIT_ASSERT( s.contains( key = 20 ) );
CPPUNIT_ASSERT( s.find_with( key, pred, 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, update_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), 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 ));
{
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, pred ));
- 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, pred) );
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, pred ));
- CPPUNIT_ASSERT( s.find(190));
+ CPPUNIT_ASSERT( s.contains(151));
+ CPPUNIT_ASSERT( s.contains(174, pred ));
+ CPPUNIT_ASSERT( s.contains(190));
{
copy_found<item> f;
}
};
- struct ensure_functor {
+ struct update_functor {
template <typename Item>
void operator()( bool bNew, Item& e, Item& arg )
{
CPPUNIT_ASSERT( s.empty() );
CPPUNIT_ASSERT( s.size() == 0 );
- CPPUNIT_ASSERT( !s.find(k1));
- CPPUNIT_ASSERT( !s.find_with(k2, typename std::conditional<Set::c_isSorted, less2, equal_to2>::type() ));
- CPPUNIT_ASSERT( !s.find(k3));
+ CPPUNIT_ASSERT( !s.contains(k1));
+ CPPUNIT_ASSERT( !s.contains(k2, typename std::conditional<Set::c_isSorted, less2, equal_to2>::type() ));
+ CPPUNIT_ASSERT( !s.contains(k3));
CPPUNIT_ASSERT( s.insert(e1));
- CPPUNIT_ASSERT( s.find(e1));
- CPPUNIT_ASSERT( s.find(k1));
- CPPUNIT_ASSERT( s.find_with(k1, typename std::conditional<Set::c_isSorted, less2, equal_to2>::type()));
- CPPUNIT_ASSERT( !s.find(e2));
- CPPUNIT_ASSERT( !s.find(e3));
+ CPPUNIT_ASSERT( s.contains(e1));
+ CPPUNIT_ASSERT( s.contains(k1));
+ CPPUNIT_ASSERT( s.contains(k1, typename std::conditional<Set::c_isSorted, less2, equal_to2>::type()));
+ CPPUNIT_ASSERT( !s.contains(e2));
+ CPPUNIT_ASSERT( !s.contains(e3));
CPPUNIT_ASSERT( e2.nInsertCount == 0 );
CPPUNIT_ASSERT( s.insert(e2, insert_functor() ));
CPPUNIT_ASSERT( e3.nEnsureNewCount == 0 );
CPPUNIT_ASSERT( e3.nEnsureCount == 0 );
- CPPUNIT_ASSERT( s.ensure( e3, ensure_functor() ) == std::make_pair(true, true));
+ CPPUNIT_ASSERT(s.update(e3, update_functor(), false) == std::make_pair(false, false));
+ CPPUNIT_ASSERT(e3.nEnsureNewCount == 0);
+ CPPUNIT_ASSERT(e3.nEnsureCount == 0);
+ CPPUNIT_ASSERT( s.update( e3, update_functor() ) == std::make_pair(true, true));
CPPUNIT_ASSERT( e3.nEnsureNewCount == 1 );
CPPUNIT_ASSERT( e3.nEnsureCount == 0 );
CPPUNIT_ASSERT( s.find_with(find_key(k1), typename std::conditional<Set::c_isSorted, less2, equal_to2>::type(), find_functor() ));
CPPUNIT_ASSERT( s.find_with(k2, typename std::conditional<Set::c_isSorted, less2, equal_to2>::type(), find_functor() ));
CPPUNIT_ASSERT( e2.nFindCount == s2.nFindCount + 1 );
CPPUNIT_ASSERT( e2.nFindArgCount == s2.nFindArgCount );
- CPPUNIT_ASSERT( s.find_with(find_key(k2), typename std::conditional<Set::c_isSorted, less2, equal_to2>::type() ));
+ CPPUNIT_ASSERT( s.contains(find_key(k2), typename std::conditional<Set::c_isSorted, less2, equal_to2>::type() ));
CPPUNIT_ASSERT( e2.nFindCount == s2.nFindCount + 1 ) ; // unchanged, no find_functor
CPPUNIT_ASSERT( e2.nFindArgCount == s2.nFindArgCount );
- CPPUNIT_ASSERT( s.find_with(k3, typename std::conditional<Set::c_isSorted, less2, equal_to2>::type() ));
+ CPPUNIT_ASSERT( s.contains(k3, typename std::conditional<Set::c_isSorted, less2, equal_to2>::type() ));
CPPUNIT_ASSERT( e3.nFindCount == s3.nFindCount ) ; // unchanged, no find_functor
CPPUNIT_ASSERT( e3.nFindArgCount == s3.nFindArgCount );
CPPUNIT_ASSERT( s.find_with(find_key(k3), typename std::conditional<Set::c_isSorted, less2, equal_to2>::type(), find_functor() ));
CPPUNIT_ASSERT( !s.insert( eu, insert_functor() ));
CPPUNIT_ASSERT( e2.nInsertCount == s2.nInsertCount );
- CPPUNIT_ASSERT( s.ensure( eu, ensure_functor()) == std::make_pair(true, false));
+ CPPUNIT_ASSERT( s.update( eu, update_functor()) == std::make_pair(true, false));
CPPUNIT_ASSERT( e2.nInsertCount == s2.nInsertCount );
CPPUNIT_ASSERT( e2.nEnsureCount == s2.nEnsureCount + 1 );
CPPUNIT_ASSERT( e2.nEnsureNewCount == s2.nEnsureNewCount );
CPPUNIT_ASSERT_EX( s.insert( *p, insert_functor() ), "i=" << i );
CPPUNIT_ASSERT_EX( p->nInsertCount == 1, "i=" << i );
//for ( size_t j = 0; j <= i; ++j ) {
- // if ( !s.find((int) j) ) {
+ // if ( !s.contains((int) j) ) {
// CPPUNIT_MSG( "Key " << j << " is not found after inserting key " << i );
// }
//}
}
for ( size_t i = 0; i < nSize; ++i )
- CPPUNIT_ASSERT_EX( s.find((int) i), "Key " << i << " is not found" );
+ CPPUNIT_ASSERT_EX( s.contains((int) i), "Key " << i << " is not found" );
CPPUNIT_ASSERT( !s.empty() );
CPPUNIT_ASSERT( s.size() == nSize );
unsigned int nFindCount ; // count of find-functor calling
unsigned int nFindArgCount;
unsigned int nInsertCount;
- unsigned int nEnsureNewCount;
- unsigned int nEnsureCount;
+ unsigned int nUpdateNewCount;
+ unsigned int nUpdateCount;
unsigned int nEraseCount;
stat()
}
};
- struct ensure_functor {
+ struct update_functor {
template <typename Item>
void operator()( bool bNew, Item& e, Item& arg )
{
if ( bNew ) {
- ++e.nEnsureNewCount;
+ ++e.nUpdateNewCount;
CPPUNIT_ASSERT_CURRENT( &e == &arg );
}
else
- ++e.nEnsureCount;
+ ++e.nUpdateCount;
}
};
CPPUNIT_ASSERT( s.empty() );
CPPUNIT_ASSERT( s.size() == 0 );
- CPPUNIT_ASSERT( !s.find(k1));
- CPPUNIT_ASSERT( !s.find(k2));
- CPPUNIT_ASSERT( !s.find(k3));
+ CPPUNIT_ASSERT( !s.contains(k1));
+ CPPUNIT_ASSERT( !s.contains(k2));
+ CPPUNIT_ASSERT( !s.contains(k3));
CPPUNIT_ASSERT( s.insert(e1));
- CPPUNIT_ASSERT( s.find(e1));
- CPPUNIT_ASSERT( s.find(k1));
- CPPUNIT_ASSERT( !s.find(e2));
- CPPUNIT_ASSERT( !s.find(e3));
+ CPPUNIT_ASSERT( s.contains(e1));
+ CPPUNIT_ASSERT( s.contains(k1));
+ CPPUNIT_ASSERT( !s.contains(e2));
+ CPPUNIT_ASSERT( !s.contains(e3));
CPPUNIT_ASSERT( e2.nInsertCount == 0 );
CPPUNIT_ASSERT( s.insert(e2, insert_functor() ));
s1 = e1 ; s2 = e2 ; s3 = e3;
- CPPUNIT_ASSERT( e3.nEnsureNewCount == 0 );
- CPPUNIT_ASSERT( e3.nEnsureCount == 0 );
- CPPUNIT_ASSERT( s.ensure( e3, ensure_functor() ) == std::make_pair(true, true));
- CPPUNIT_ASSERT( e3.nEnsureNewCount == 1 );
- CPPUNIT_ASSERT( e3.nEnsureCount == 0 );
+ CPPUNIT_ASSERT( e3.nUpdateNewCount == 0 );
+ CPPUNIT_ASSERT( e3.nUpdateCount == 0 );
+ CPPUNIT_ASSERT(s.update(e3, update_functor(), false) == std::make_pair(false, false));
+ CPPUNIT_ASSERT(e3.nUpdateNewCount == 0);
+ CPPUNIT_ASSERT(e3.nUpdateCount == 0);
+ CPPUNIT_ASSERT( s.update( e3, update_functor() ) == std::make_pair(true, true));
+ CPPUNIT_ASSERT( e3.nUpdateNewCount == 1 );
+ CPPUNIT_ASSERT( e3.nUpdateCount == 0 );
CPPUNIT_ASSERT( s.find_with(find_key(k1), less2(), find_functor() ));
CPPUNIT_ASSERT( e1.nFindCount == s1.nFindCount + 1 );
CPPUNIT_ASSERT( e1.nFindArgCount == s1.nFindArgCount );
CPPUNIT_ASSERT( s.find_with(k2, less2(), find_functor() ));
CPPUNIT_ASSERT( e2.nFindCount == s2.nFindCount + 1 );
CPPUNIT_ASSERT( e2.nFindArgCount == s2.nFindArgCount );
- CPPUNIT_ASSERT( s.find_with(find_key(k2), less2() ));
+ CPPUNIT_ASSERT( s.contains(find_key(k2), less2() ));
CPPUNIT_ASSERT( e2.nFindCount == s2.nFindCount + 1 ) ; // unchanged, no find_functor
CPPUNIT_ASSERT( e2.nFindArgCount == s2.nFindArgCount );
- CPPUNIT_ASSERT( s.find_with(k3, less2() ));
+ CPPUNIT_ASSERT( s.contains(k3, less2() ));
CPPUNIT_ASSERT( e3.nFindCount == s3.nFindCount ) ; // unchanged, no find_functor
CPPUNIT_ASSERT( e3.nFindArgCount == s3.nFindArgCount );
CPPUNIT_ASSERT( s.find_with(find_key(k3), less2(), find_functor() ));
CPPUNIT_ASSERT( !s.insert( eu, insert_functor() ));
CPPUNIT_ASSERT( e2.nInsertCount == s2.nInsertCount );
- CPPUNIT_ASSERT( s.ensure( eu, ensure_functor()) == std::make_pair(true, false));
+ CPPUNIT_ASSERT( s.update( eu, update_functor()) == std::make_pair(true, false));
CPPUNIT_ASSERT( e2.nInsertCount == s2.nInsertCount );
- CPPUNIT_ASSERT( e2.nEnsureCount == s2.nEnsureCount + 1 );
- CPPUNIT_ASSERT( e2.nEnsureNewCount == s2.nEnsureNewCount );
+ CPPUNIT_ASSERT( e2.nUpdateCount == s2.nUpdateCount + 1 );
+ CPPUNIT_ASSERT( e2.nUpdateNewCount == s2.nUpdateNewCount );
}
s1 = e1 ; s2 = e2 ; s3 = e3;
CPPUNIT_ASSERT_EX( s.insert( *p, insert_functor() ), "i=" << i );
CPPUNIT_ASSERT_EX( p->nInsertCount == 1, "i=" << i );
//for ( size_t j = 0; j <= i; ++j ) {
- // if ( !s.find((int) j) ) {
+ // if ( !s.contains((int) j) ) {
// CPPUNIT_MSG( "Key " << j << " is not found after inserting key " << i );
// }
//}
}
for ( size_t i = 0; i < nSize; ++i )
- CPPUNIT_ASSERT_EX( s.find((int) i), "Key " << i << " is not found" );
+ CPPUNIT_ASSERT_EX( s.contains((int) i), "Key " << i << " is not found" );
CPPUNIT_ASSERT( !s.empty() );
CPPUNIT_ASSERT( s.size() == nSize );
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 update_func( bool bNew, Item& i, Q& /*val*/ )
{
if ( bNew )
- ++i.nEnsureNewCount;
+ ++i.nUpdateNewCount;
else
- ++i.nEnsureCount;
+ ++i.nUpdateCount;
}
- struct ensure_functor
+ struct update_functor
{
template <typename Item, typename Q>
void operator()( bool bNew, Item& i, Q& val )
{
- ensure_func( bNew, i, val );
+ update_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( 20 ) );
+ CPPUNIT_ASSERT( !s.contains( 20 ) );
CPPUNIT_ASSERT( s.insert( std::make_pair(20, 25) ));
CPPUNIT_ASSERT( !s.empty() );
CPPUNIT_ASSERT( check_size( s, 2 ));
- CPPUNIT_ASSERT( s.find( 10 ) );
- CPPUNIT_ASSERT( s.find( key = 20 ) );
+ CPPUNIT_ASSERT( s.contains( 10 ) );
+ CPPUNIT_ASSERT( s.contains( key = 20 ) );
CPPUNIT_ASSERT( s.find( key, 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, update_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), 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 ));
{
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( 10 ));
- CPPUNIT_ASSERT( !s.find( 10 ));
+ CPPUNIT_ASSERT( !s.contains( 10 ));
CPPUNIT_ASSERT( !s.empty() );
CPPUNIT_ASSERT( check_size( s, 2 ));
CPPUNIT_ASSERT( !s.erase(10) );
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(174));
- CPPUNIT_ASSERT( s.find(190));
+ CPPUNIT_ASSERT( s.contains(151));
+ CPPUNIT_ASSERT( s.contains(174));
+ CPPUNIT_ASSERT( s.contains(190));
{
copy_found<item> f;
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( 10 ) );
- CPPUNIT_ASSERT( s.find_with( key = 20, less<value_type>() ) );
+ CPPUNIT_ASSERT( s.contains( 10 ) );
+ CPPUNIT_ASSERT( s.contains( key = 20, less<value_type>() ) );
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, update_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), 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 ));
{
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(174));
- CPPUNIT_ASSERT( s.find(190));
+ CPPUNIT_ASSERT( s.contains(151));
+ CPPUNIT_ASSERT( s.contains(174));
+ CPPUNIT_ASSERT( s.contains(190));
{
copy_found<item> f;