//$$CDS-header$$
#include "cppunit/cppunit_proxy.h"
-#include <cds/container/lazy_list_base.h>
+#include <cds/container/details/lazy_list_base.h>
namespace ordlist {
namespace cc = cds::container;
struct ensure_functor {
template <typename T>
- void operator()( bool bNew, T& pair )
+ void operator()( bool /*bNew*/, T& pair )
{
pair.second.m_val = pair.first * 50;
}
CPPUNIT_ASSERT( l.find( 100 ));
check_value chk(0);
- CPPUNIT_ASSERT( l.find( 100, boost::ref( chk ) ));
+ CPPUNIT_ASSERT( l.find( 100, std::ref( chk ) ) );
CPPUNIT_ASSERT( !l.find_with( 50, lt<key_type>() ));
CPPUNIT_ASSERT( l.insert( 50, 500 ));
CPPUNIT_ASSERT( l.find_with( 50, lt<key_type>() ));
CPPUNIT_ASSERT( !l.insert( 50, 5 ));
chk.m_nExpected = 500;
- CPPUNIT_ASSERT( l.find( 50, boost::ref( chk ) ));
+ CPPUNIT_ASSERT( l.find( 50, std::ref( chk ) ) );
chk.m_nExpected = 0;
- CPPUNIT_ASSERT( l.find( 100, boost::ref( chk ) ));
+ CPPUNIT_ASSERT( l.find( 100, std::ref( chk ) ) );
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>(), boost::ref( chk ) ));
+ CPPUNIT_ASSERT( l.find_with( 150, lt<key_type>(), std::ref( chk ) ) );
chk.m_nExpected = 0;
- CPPUNIT_ASSERT( l.find( 100, boost::ref( chk ) ));
+ CPPUNIT_ASSERT( l.find( 100, std::ref( chk ) ) );
chk.m_nExpected = 500;
- CPPUNIT_ASSERT( l.find( 50, boost::ref( chk ) ));
+ CPPUNIT_ASSERT( l.find( 50, std::ref( chk ) ) );
CPPUNIT_ASSERT( !l.empty() );
// erase test
CPPUNIT_ASSERT( l.find( 50 ));
{
erase_functor ef;
- l.erase( 50, boost::ref(ef));
+ l.erase( 50, std::ref( ef ) );
CPPUNIT_ASSERT( ef.nKey == 50 );
CPPUNIT_ASSERT( ef.nVal == 500 );
}
CPPUNIT_ASSERT( bEnsureResult.first );
CPPUNIT_ASSERT( !bEnsureResult.second );
chk.m_nExpected = 5000;
- CPPUNIT_ASSERT( l.find( 100, boost::ref( chk ) ));
+ CPPUNIT_ASSERT( l.find( 100, std::ref( chk ) ) );
{
ensure_functor ef;
- bEnsureResult = l.ensure( 50, boost::ref( ef ));
+ bEnsureResult = l.ensure( 50, std::ref( ef ) );
}
CPPUNIT_ASSERT( bEnsureResult.first );
CPPUNIT_ASSERT( bEnsureResult.second );
chk.m_nExpected = 2500;
- CPPUNIT_ASSERT( l.find( 50, boost::ref( chk ) ));
+ CPPUNIT_ASSERT( l.find( 50, 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 ));
{
erase_functor ef;
- CPPUNIT_ASSERT( l.erase_with( 200, lt<key_type>(), cds::ref(ef)) );
+ CPPUNIT_ASSERT( l.erase_with( 200, lt<key_type>(), std::ref(ef)) );
CPPUNIT_ASSERT( ef.nKey == 200 );
CPPUNIT_ASSERT( ef.nVal == 2000 );
}
l.clear();
CPPUNIT_ASSERT( l.empty() );
-#ifdef CDS_EMPLACE_SUPPORT
// insert test
CPPUNIT_ASSERT( l.emplace( 501 ) );
CPPUNIT_ASSERT( l.emplace( 251, 152 ));
CPPUNIT_ASSERT( !l.emplace( 251, 10) );
check_value cv(0);
- CPPUNIT_ASSERT( l.find( 501, cds::ref(cv) ));
+ CPPUNIT_ASSERT( l.find( 501, std::ref(cv) ));
cv.m_nExpected = 152;
- CPPUNIT_ASSERT( l.find( 251, cds::ref(cv) ));
+ CPPUNIT_ASSERT( l.find( 251, std::ref(cv) ));
l.clear();
CPPUNIT_ASSERT( l.empty() );
-#endif
// Iterator test
{
for ( int i = 0; i < nCount; ++i )
CPPUNIT_ASSERT( l.insert(i, i * 2 ) );
+ {
+ typename OrdList::iterator it( l.begin() );
+ typename OrdList::const_iterator cit( l.cbegin() );
+ CPPUNIT_CHECK( it == cit );
+ CPPUNIT_CHECK( it != l.end() );
+ CPPUNIT_CHECK( it != l.cend() );
+ CPPUNIT_CHECK( cit != l.end() );
+ CPPUNIT_CHECK( cit != l.cend() );
+ ++it;
+ CPPUNIT_CHECK( it != cit );
+ CPPUNIT_CHECK( it != l.end() );
+ CPPUNIT_CHECK( it != l.cend() );
+ CPPUNIT_CHECK( cit != l.end() );
+ CPPUNIT_CHECK( cit != l.cend() );
+ ++cit;
+ CPPUNIT_CHECK( it == cit );
+ CPPUNIT_CHECK( it != l.end() );
+ CPPUNIT_CHECK( it != l.cend() );
+ CPPUNIT_CHECK( cit != l.end() );
+ CPPUNIT_CHECK( cit != l.cend() );
+ }
+
int i = 0;
for ( typename OrdList::iterator it = l.begin(), itEnd = l.end(); it != itEnd; ++it, ++i ) {
CPPUNIT_ASSERT( it.key() == i );
// Check that we have visited all items
for ( int i = 0; i < nCount; ++i ) {
chk.m_nExpected = i * 3;
- CPPUNIT_ASSERT( l.find( i, boost::ref(chk) ));
+ CPPUNIT_ASSERT( l.find( i, std::ref( chk ) ) );
}
l.clear();
// Check that we have visited all items
for ( int i = nCount; i > 0; --i ) {
chk.m_nExpected = (i - 1) * 7;
- CPPUNIT_ASSERT( l.find_with( i - 1, lt<key_type>(), boost::ref(chk) ));
+ CPPUNIT_ASSERT( l.find_with( i - 1, lt<key_type>(), std::ref( chk ) ) );
}
l.clear();
for ( int i = 0; i < nLimit; ++i ) {
int nKey = arr[i];
- CPPUNIT_ASSERT( l.get(gp, nKey));
+ gp = l.get( nKey );
+ CPPUNIT_ASSERT( gp );
CPPUNIT_ASSERT( !gp.empty());
CPPUNIT_CHECK( gp->first == nKey );
CPPUNIT_CHECK( gp->second.m_val == nKey * 2 );
gp.release();
- CPPUNIT_ASSERT( l.extract(gp, nKey));
+ gp = l.extract( nKey );
+ CPPUNIT_ASSERT( gp );
CPPUNIT_ASSERT( !gp.empty());
CPPUNIT_CHECK( gp->first == nKey );
CPPUNIT_CHECK( gp->second.m_val == nKey*2 );
gp.release();
- CPPUNIT_CHECK( !l.get(gp, nKey));
+ gp = l.get( nKey );
+ CPPUNIT_CHECK( !gp );
CPPUNIT_CHECK( gp.empty());
- CPPUNIT_CHECK( !l.extract( gp, nKey));
+ CPPUNIT_CHECK( !l.extract( nKey));
CPPUNIT_CHECK( gp.empty());
}
CPPUNIT_ASSERT( l.empty());
- CPPUNIT_CHECK( !l.get(gp, arr[0]));
+ CPPUNIT_CHECK( !l.get(arr[0]));
CPPUNIT_CHECK( gp.empty());
- CPPUNIT_CHECK( !l.extract( gp, arr[0]));
+ CPPUNIT_CHECK( !l.extract( arr[0]));
CPPUNIT_CHECK( gp.empty());
}
int nKey = arr[i];
other_key key = float(nKey + 0.3);
- CPPUNIT_ASSERT( l.get_with(gp, key, other_less()));
+ gp = l.get_with( key, other_less() );
+ CPPUNIT_ASSERT( gp );
CPPUNIT_ASSERT( !gp.empty());
CPPUNIT_CHECK( gp->first == nKey );
CPPUNIT_CHECK( gp->second.m_val == nKey * 2 );
gp.release();
- CPPUNIT_ASSERT( l.extract_with(gp, key, other_less()));
+ gp = l.extract_with( key, other_less() );
+ CPPUNIT_ASSERT( gp );
CPPUNIT_ASSERT( !gp.empty());
CPPUNIT_CHECK( gp->first == nKey );
CPPUNIT_CHECK( gp->second.m_val == nKey*2 );
gp.release();
- CPPUNIT_CHECK( !l.get_with(gp, key, other_less()));
+ gp = l.get_with( key, other_less() );
+ CPPUNIT_CHECK( !gp );
CPPUNIT_CHECK( gp.empty());
- CPPUNIT_CHECK( !l.extract_with( gp, key, other_less()));
+ CPPUNIT_CHECK( !l.extract_with( key, other_less()));
CPPUNIT_CHECK( gp.empty());
}
CPPUNIT_ASSERT( l.empty());
- CPPUNIT_CHECK( !l.get_with(gp, 3.4f, other_less()));
+ CPPUNIT_CHECK( !l.get_with(3.4f, other_less()));
CPPUNIT_CHECK( gp.empty());
- CPPUNIT_CHECK( !l.extract_with( gp, 3.4f, other_less()));
+ CPPUNIT_CHECK( !l.extract_with( 3.4f, other_less()));
CPPUNIT_CHECK( gp.empty());
}
}
{
rcu_lock lock;
value_type * pGet = l.get( a[i] );
- CPPUNIT_ASSERT( pGet != NULL );
+ CPPUNIT_ASSERT( pGet != nullptr );
CPPUNIT_CHECK( pGet->first == a[i] );
CPPUNIT_CHECK( pGet->second.m_val == a[i] * 2 );
- CPPUNIT_ASSERT( l.extract( ep, a[i] ));
+ ep = l.extract( a[i] );
+ CPPUNIT_ASSERT( ep );
CPPUNIT_ASSERT( !ep.empty() );
CPPUNIT_CHECK( ep->first == a[i] );
CPPUNIT_CHECK( (*ep).second.m_val == a[i] * 2 );
ep.release();
{
rcu_lock lock;
- CPPUNIT_CHECK( l.get( a[i]) == NULL );
- CPPUNIT_CHECK( !l.extract( ep, a[i] ));
+ CPPUNIT_CHECK( l.get( a[i] ) == nullptr );
+ ep = l.extract( a[i] );
+ CPPUNIT_CHECK( !ep );
CPPUNIT_CHECK( ep.empty() );
}
}
{
rcu_lock lock;
- CPPUNIT_CHECK( l.get( a[0] ) == NULL );
- CPPUNIT_CHECK( !l.extract( ep, a[0] ) );
- CPPUNIT_CHECK( ep.empty() );
+ CPPUNIT_CHECK( l.get( a[0] ) == nullptr );
+ CPPUNIT_CHECK( !l.extract( a[0] ) );
}
// extract_with/get_with
{
rcu_lock lock;
value_type * pGet = l.get_with( itm, other_less() );
- CPPUNIT_ASSERT( pGet != NULL );
+ CPPUNIT_ASSERT( pGet != nullptr );
CPPUNIT_CHECK( pGet->first == a[i] );
CPPUNIT_CHECK( pGet->second.m_val == a[i] * 2 );
- CPPUNIT_ASSERT( l.extract_with( ep, itm, other_less() ));
+ ep = l.extract_with( itm, other_less() );
+ CPPUNIT_ASSERT( ep );
CPPUNIT_ASSERT( !ep.empty() );
CPPUNIT_CHECK( ep->first == a[i] );
CPPUNIT_CHECK( ep->second.m_val == a[i] * 2 );
ep.release();
{
rcu_lock lock;
- CPPUNIT_CHECK( l.get_with( itm, other_less()) == NULL );
- CPPUNIT_CHECK( !l.extract_with( ep, itm, other_less() ));
+ CPPUNIT_CHECK( l.get_with( itm, other_less()) == nullptr );
+ ep = l.extract_with( itm, other_less() );
+ CPPUNIT_CHECK( !ep );
CPPUNIT_CHECK( ep.empty() );
}
}
{
rcu_lock lock;
- CPPUNIT_CHECK( l.get_with( 3.14f, other_less() ) == NULL );
- CPPUNIT_CHECK( !l.extract_with( ep, 3.14f, other_less() ));
+ CPPUNIT_CHECK( l.get_with( 3.14f, other_less() ) == nullptr );
+ CPPUNIT_CHECK( !l.extract_with( 3.14f, other_less() ));
CPPUNIT_CHECK( ep.empty() );
}
}
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 );
l.clear();
CPPUNIT_ASSERT( l.empty() );
-#ifdef CDS_EMPLACE_SUPPORT
// insert test
CPPUNIT_ASSERT( l.emplace( 501 ) != l.end());
CPPUNIT_ASSERT( l.emplace( 251, 152 ) != l.end());
l.clear();
CPPUNIT_ASSERT( l.empty() );
-#endif
// Iterator test
{
for ( int i = 0; i < nCount; ++i )
CPPUNIT_ASSERT( l.insert(i, i * 2 ) != l.end() );
+ {
+ typename OrdList::iterator it( l.begin() );
+ typename OrdList::const_iterator cit( l.cbegin() );
+ CPPUNIT_CHECK( it == cit );
+ CPPUNIT_CHECK( it != l.end() );
+ CPPUNIT_CHECK( it != l.cend() );
+ CPPUNIT_CHECK( cit != l.end() );
+ CPPUNIT_CHECK( cit != l.cend() );
+ ++it;
+ CPPUNIT_CHECK( it != cit );
+ CPPUNIT_CHECK( it != l.end() );
+ CPPUNIT_CHECK( it != l.cend() );
+ CPPUNIT_CHECK( cit != l.end() );
+ CPPUNIT_CHECK( cit != l.cend() );
+ ++cit;
+ CPPUNIT_CHECK( it == cit );
+ CPPUNIT_CHECK( it != l.end() );
+ CPPUNIT_CHECK( it != l.cend() );
+ CPPUNIT_CHECK( cit != l.end() );
+ CPPUNIT_CHECK( cit != l.cend() );
+ }
+
int i = 0;
for ( typename OrdList::iterator iter = l.begin(), itEnd = l.end(); iter != itEnd; ++iter, ++i ) {
CPPUNIT_ASSERT( iter.key() == i );
void HP_cmpmix();
void HP_ic();
- void PTB_cmp();
- void PTB_less();
- void PTB_cmpmix();
- void PTB_ic();
+ void DHP_cmp();
+ void DHP_less();
+ void DHP_cmpmix();
+ void DHP_ic();
void RCU_GPI_cmp();
void RCU_GPI_less();
void RCU_SHT_cmpmix();
void RCU_SHT_ic();
- void HRC_cmp();
- void HRC_less();
- void HRC_cmpmix();
- void HRC_ic();
-
void NOGC_cmp();
void NOGC_less();
void NOGC_cmpmix();
CPPUNIT_TEST(HP_cmpmix)
CPPUNIT_TEST(HP_ic)
- CPPUNIT_TEST(PTB_cmp)
- CPPUNIT_TEST(PTB_less)
- CPPUNIT_TEST(PTB_cmpmix)
- CPPUNIT_TEST(PTB_ic)
-
- CPPUNIT_TEST(HRC_cmp)
- CPPUNIT_TEST(HRC_less)
- CPPUNIT_TEST(HRC_cmpmix)
- CPPUNIT_TEST(HRC_ic)
+ CPPUNIT_TEST(DHP_cmp)
+ CPPUNIT_TEST(DHP_less)
+ CPPUNIT_TEST(DHP_cmpmix)
+ CPPUNIT_TEST(DHP_ic)
CPPUNIT_TEST(RCU_GPI_cmp)
CPPUNIT_TEST(RCU_GPI_less)