++it; // skip dummy head
return it;
}
- const_iterator cbegin()
+ const_iterator cbegin() const
{
const_iterator it( head() );
++it; // skip dummy head
{
return const_iterator( tail());
}
- const_iterator cend()
+ const_iterator cend() const
{
return const_iterator( tail());
}
++it ; // skip dummy head node
return it;
}
- const_iterator cbegin()
+ const_iterator cbegin() const
{
const_iterator it( head() );
++it ; // skip dummy head node
{
return const_iterator( tail() );
}
- const_iterator cend()
+ const_iterator cend() const
{
return const_iterator( tail() );
}
{
return const_iterator( head() );
}
- const_iterator cbegin()
+ const_iterator cbegin() const
{
return const_iterator( head() );
}
{
return const_iterator();
}
- const_iterator cend()
+ const_iterator cend() const
{
return const_iterator();
}
{
return const_iterator( head() );
}
- const_iterator cbegin()
+ const_iterator cbegin() const
{
return const_iterator( head() );
}
{
return const_iterator();
}
- const_iterator cend()
+ const_iterator cend() const
{
return const_iterator();
}
{
return cbegin();
}
- const_iterator cbegin()
+ const_iterator cbegin() const
{
return const_iterator( base_class::cbegin() );
}
{
return cend();
}
- const_iterator cend()
+ const_iterator cend() const
{
return const_iterator( base_class::cend() );
}
}
/// Returns a forward const iterator addressing the first element in a set
- const_iterator cbegin()
+ const_iterator cbegin() const
{
return const_iterator( base_class::cbegin() );
}
}
/// Returns a forward const iterator that addresses the location succeeding the last element in a set.
- const_iterator cend()
+ const_iterator cend() const
{
return const_iterator( base_class::cend() );
}
++it ; // skip dummy head
return it;
}
- const_iterator cbegin()
+ const_iterator cbegin() const
{
const_iterator it( head() );
++it ; // skip dummy head
{
return const_iterator( tail());
}
- const_iterator cend()
+ const_iterator cend() const
{
return const_iterator( tail());
}
++it; // skip dummy head
return it;
}
- const_iterator cbegin()
+ const_iterator cbegin() const
{
const_iterator it( head() );
++it; // skip dummy head
{
return const_iterator( tail());
}
- const_iterator cend()
+ const_iterator cend() const
{
return const_iterator( tail());
}
++it ; // skip dummy head node
return it;
}
- const_iterator cbegin()
+ const_iterator cbegin() const
{
const_iterator it( head() );
++it ; // skip dummy head node
{
return const_iterator( tail());
}
- const_iterator cend()
+ const_iterator cend() const
{
return const_iterator( tail());
}
++it ; // skip dummy head node
return it;
}
- const_iterator cbegin()
+ const_iterator cbegin() const
{
const_iterator it( head() );
++it ; // skip dummy head node
{
return const_iterator( tail() );
}
- const_iterator cend()
+ const_iterator cend() const
{
return const_iterator( tail() );
}
{
return const_iterator( head() );
}
- const_iterator cbegin()
+ const_iterator cbegin() const
{
return const_iterator( head() );
}
{
return const_iterator();
}
- const_iterator cend()
+ const_iterator cend() const
{
return const_iterator();
}
{
return const_iterator( head() );
}
- const_iterator cbegin()
+ const_iterator cbegin() const
{
return const_iterator( head() );
}
{
return const_iterator();
}
- const_iterator cend()
+ const_iterator cend() const
{
return const_iterator();
}
{
return const_iterator( head() );
}
- const_iterator cbegin()
+ const_iterator cbegin() const
{
return const_iterator( head() );
}
{
return const_iterator();
}
- const_iterator cend()
+ const_iterator cend() const
{
return const_iterator();
}
{
return const_iterator( head() );
}
- const_iterator cbegin()
+ const_iterator cbegin() const
{
return const_iterator( head() );
}
{
return const_iterator();
}
- const_iterator cend()
+ const_iterator cend() const
{
return const_iterator();
}
{
return get_const_begin();
}
- const_iterator cbegin()
+ const_iterator cbegin() const
{
return get_const_begin();
}
{
return get_const_end();
}
- const_iterator cend()
+ const_iterator cend() const
{
return get_const_end();
}
{
return !( *this == i );
}
-
- /// Checks if the iterator is not equal to \p end()
- explicit operator bool() const
- {
- return *this != iterator_type();
- }
};
{
return get_const_begin();
}
- const_iterator cbegin()
+ const_iterator cbegin() const
{
return get_const_begin();
}
{
return get_const_end();
}
- const_iterator cend()
+ const_iterator cend() const
{
return get_const_end();
}
{
return get_const_begin();
}
- const_iterator cbegin()
+ const_iterator cbegin() const
{
return get_const_begin();
}
{
return get_const_end();
}
- const_iterator cend()
+ const_iterator cend() const
{
return get_const_end();
}
{
return get_const_begin();
}
- const_iterator cbegin()
+ const_iterator cbegin() const
{
return get_const_begin();
}
{
return get_const_end();
}
- const_iterator cend()
+ const_iterator cend() const
{
return get_const_end();
}
{
return get_const_begin();
}
- const_iterator cbegin()
+ const_iterator cbegin() const
{
return get_const_begin();
}
{
return get_const_end();
}
- const_iterator cend()
+ const_iterator cend() const
{
return get_const_end();
}
{
return get_const_begin();
}
- const_iterator cbegin()
+ const_iterator cbegin() const
{
return get_const_begin();
}
{
return get_const_end();
}
- const_iterator cend()
+ const_iterator cend() const
{
return get_const_end();
}
{
return base_class::begin();
}
- const_iterator cbegin()
+ const_iterator cbegin() const
{
return base_class::cbegin();
}
{
return base_class::end();
}
- const_iterator cend()
+ const_iterator cend() const
{
return base_class::cend();
}
{
return cbegin();
}
- const_iterator cbegin()
+ const_iterator cbegin() const
{
return const_iterator( base_class::cbegin() );
}
{
return cend();
}
- const_iterator cend()
+ const_iterator cend() const
{
return const_iterator( base_class::cend() );
}
{
return const_iterator( base_class::begin() );
}
- const_iterator cbegin()
+ const_iterator cbegin() const
{
return const_iterator( base_class::cbegin() );
}
{
return const_iterator( base_class::end() );
}
- const_iterator cend()
+ const_iterator cend() const
{
return const_iterator( base_class::cend() );
}
{
return const_iterator( base_class::begin() );
}
- const_iterator cbegin()
+ const_iterator cbegin() const
{
return const_iterator( base_class::cbegin() );
}
{
return const_iterator( base_class::end() );
}
- const_iterator cend()
+ const_iterator cend() const
{
return const_iterator( base_class::cend() );
}
{
return base_class::begin();
}
- const_iterator cbegin()
+ const_iterator cbegin() const
{
return base_class::cbegin();
}
{
return base_class::end();
}
- const_iterator cend()
+ const_iterator cend() const
{
return base_class::cend();
}
{
return base_class::begin();
}
- const_iterator cbegin()
+ const_iterator cbegin() const
{
return base_class::cbegin();
}
{
return base_class::end();
}
- const_iterator cend()
+ const_iterator cend() const
{
return base_class::cend();
}
{
return base_class::begin();
}
- const_iterator cbegin()
+ const_iterator cbegin() const
{
return base_class::cbegin();
}
{
return base_class::end();
}
- const_iterator cend()
+ const_iterator cend() const
{
return base_class::cend();
}
/// Returns a forward const iterator addressing the first element in a set
const_iterator begin() const
{
- return const_iterator( base_class::begin() );
+ return cbegin();
+ }
+ /// Returns a forward const iterator addressing the first element in a set
+ const_iterator cbegin() const
+ {
+ return const_iterator( base_class::cbegin() );
}
/// Returns an const iterator that addresses the location succeeding the last element in a set
const_iterator end() const
{
- return const_iterator( base_class::end() );
+ return cend();
+ }
+ /// Returns an const iterator that addresses the location succeeding the last element in a set
+ const_iterator cend() const
+ {
+ return const_iterator( base_class::cend() );
}
public:
/// Returns a forward const iterator addressing the first element in a set
const_iterator begin() const
{
- return const_iterator( base_class::begin() );
+ return cbegin();
+ }
+ /// Returns a forward const iterator addressing the first element in a set
+ const_iterator cbegin() const
+ {
+ return const_iterator( base_class::cbegin() );
}
/// Returns an const iterator that addresses the location succeeding the last element in a set
const_iterator end() const
{
- return const_iterator( base_class::end() );
+ return cend();
+ }
+ /// Returns an const iterator that addresses the location succeeding the last element in a set
+ const_iterator cend() const
+ {
+ return const_iterator( base_class::cend() );
}
protected:
/// Returns a forward const iterator addressing the first element in a set
const_iterator begin() const
{
- return const_iterator( base_class::begin() );
+ return cbegin();
+ }
+ /// Returns a forward const iterator addressing the first element in a set
+ const_iterator cbegin() const
+ {
+ return const_iterator( base_class::cbegin() );
}
/// Returns an const iterator that addresses the location succeeding the last element in a set
const_iterator end() const
{
- return const_iterator( base_class::end() );
+ return cend();
+ }
+ /// Returns an const iterator that addresses the location succeeding the last element in a set
+ const_iterator cend() const
+ {
+ return const_iterator( base_class::cend() );
}
public:
template <typename OrderedList, bool IsConst>
class iterator
{
+ friend class iterator < OrderedList, !IsConst > ;
protected:
typedef OrderedList bucket_type;
typedef typename list_iterator_selector< bucket_type, IsConst>::bucket_ptr bucket_ptr;
list_iterator m_itList;
bucket_ptr m_pEndBucket;
+ friend class iterator < bucket_type, !IsConst > ;
+
void next()
{
if ( m_pCurBucket < m_pEndBucket ) {
}
template <bool C>
- bool operator ==(iterator<OrderedList, C> const& i ) const
+ bool operator ==(iterator<bucket_type, C> const& i) const
{
return m_pCurBucket == i.m_pCurBucket && m_itList == i.m_itList;
}
class iterator_type
{
typedef OrderedList ordered_list_type;
+ friend class iterator_type <NodeTraits, OrderedList, !IsConst >;
+
protected:
typedef typename select_list_iterator<ordered_list_type, IsConst>::type list_iterator;
typedef NodeTraits node_traits;
{
return get_const_begin();
}
- const_iterator cbegin()
+ const_iterator cbegin() const
{
return get_const_begin();
}
{
return get_const_end();
}
- const_iterator cend()
+ const_iterator cend() const
{
return get_const_end();
}
}
/// Returns a forward const iterator addressing the first element in a list
- const_iterator cbegin()
+ const_iterator cbegin() const
{
return const_iterator( m_pHead );
}
}
/// Returns an const iterator that addresses the location succeeding the last element in a list
- const_iterator cend()
+ const_iterator cend() const
{
return const_iterator();
}
{
return const_iterator( *m_Head.head() );
}
- const_iterator cbegin()
+ const_iterator cbegin() const
{
return const_iterator( *m_Head.head() );
}
{
return const_iterator();
}
- const_iterator cend()
+ const_iterator cend() const
{
return const_iterator();
}
/// Returns a forward const iterator addressing the first element in a list
const_iterator begin() const
{
- const_iterator it( const_cast<node_type *>( &m_Head ));
- ++it ; // skip dummy head
+ return cbegin();
+ }
+ /// Returns a forward const iterator addressing the first element in a list
+ const_iterator cbegin() const
+ {
+ const_iterator it( const_cast<node_type *>(&m_Head) );
+ ++it; // skip dummy head
return it;
}
/// Returns an const iterator that addresses the location succeeding the last element in a list
const_iterator end() const
{
- return const_iterator( const_cast<node_type *>( &m_Tail ));
+ return cend();
+ }
+ const_iterator cend() const
+ {
+ return const_iterator( const_cast<node_type *>(&m_Tail) );
}
public:
{
return get_const_begin();
}
- const_iterator cbegin()
+ const_iterator cbegin() const
{
return get_const_begin();
}
{
return get_const_end();
}
- const_iterator cend()
+ const_iterator cend() const
{
return get_const_end();
}
return const_iterator(m_pHead.load(memory_model::memory_order_relaxed) );
}
/// Returns a forward const iterator addressing the first element in a list
- const_iterator cbegin()
+ const_iterator cbegin() const
{
return const_iterator(m_pHead.load(memory_model::memory_order_relaxed) );
}
return const_iterator(m_pHead );
}
/// Returns a forward const iterator addressing the first element in a list
- const_iterator cbegin()
+ const_iterator cbegin() const
{
return const_iterator(m_pHead );
}
return const_iterator();
}
/// Returns an const iterator that addresses the location succeeding the last element in a list
- const_iterator cend()
+ const_iterator cend() const
{
return const_iterator();
}
{
return get_const_begin();
}
- const_iterator cbegin()
+ const_iterator cbegin() const
{
return get_const_begin();
}
{
return get_const_end();
}
- const_iterator cend()
+ const_iterator cend() const
{
return get_const_end();
}
//@cond
const_iterator get_const_begin() const
{
- return const_iterator( m_Buckets[0].begin(), m_Buckets, m_Buckets + bucket_count() );
+ return const_iterator( m_Buckets[0].cbegin(), m_Buckets, m_Buckets + bucket_count() );
}
const_iterator get_const_end() const
{
- return const_iterator( m_Buckets[bucket_count() - 1].end(), m_Buckets + bucket_count() - 1, m_Buckets + bucket_count() );
+ return const_iterator( m_Buckets[bucket_count() - 1].cend(), m_Buckets + bucket_count() - 1, m_Buckets + bucket_count() );
}
//@endcond
//@{
const_iterator begin() const
{
- return get_const_begin();
+ return cbegin();
}
- const_iterator cbegin()
+ const_iterator cbegin() const
{
- return get_const_begin();
+ return const_iterator( m_Buckets[0].cbegin(), m_Buckets, m_Buckets + bucket_count() );
}
//@}
//@{
const_iterator end() const
{
- return get_const_end();
+ return cend();
}
- const_iterator cend()
+ const_iterator cend() const
{
- return get_const_end();
+ return const_iterator( m_Buckets[bucket_count() - 1].cend(), m_Buckets + bucket_count() - 1, m_Buckets + bucket_count() );
}
//@}
- private:
- //@cond
- const_iterator get_const_begin() const
- {
- return const_iterator( m_Buckets[0].begin(), m_Buckets, m_Buckets + bucket_count() );
- }
- const_iterator get_const_end() const
- {
- return const_iterator( m_Buckets[bucket_count() - 1].end(), m_Buckets + bucket_count() - 1, m_Buckets + bucket_count() );
- }
- //@endcond
-
public:
/// Initializes hash set
/** @copydetails cds_intrusive_MichaelHashSet_hp_ctor
//@{
const_iterator begin() const
{
- return get_const_begin();
+ return cbegin();
}
- const_iterator cbegin()
+ const_iterator cbegin() const
{
- return get_const_begin();
+ return const_iterator( m_Buckets[0].cbegin(), m_Buckets, m_Buckets + bucket_count() );
}
//@}
//@{
const_iterator end() const
{
- return get_const_end();
+ return cend();
}
- const_iterator cend()
+ const_iterator cend() const
{
- return get_const_end();
+ return const_iterator( m_Buckets[bucket_count() - 1].cend(), m_Buckets + bucket_count() - 1, m_Buckets + bucket_count() );
}
//@}
- private:
- //@cond
- const_iterator get_const_begin() const
- {
- return const_iterator( m_Buckets[0].begin(), m_Buckets, m_Buckets + bucket_count() );
- }
- const_iterator get_const_end() const
- {
- return const_iterator( m_Buckets[bucket_count() - 1].end(), m_Buckets + bucket_count() - 1, m_Buckets + bucket_count() );
- }
- //@endcond
-
public:
/// Initialize hash set
/**
{
return const_iterator( *m_Head.head() );
}
- const_iterator cbegin()
+ const_iterator cbegin() const
{
return const_iterator( *m_Head.head() );
}
{
return const_iterator();
}
- const_iterator cend()
+ const_iterator cend() const
{
return const_iterator();
}
}
/// Returns a forward const iterator addressing the first element in a set
- const_iterator cbegin()
+ const_iterator cbegin() const
{
return const_iterator( *m_Head.head() );
}
}
/// Returns a forward const iterator that addresses the location succeeding the last element in a set.
- const_iterator cend()
+ const_iterator cend() const
{
return const_iterator();
}
/// Returns a forward const iterator addressing the first element in a split-list
const_iterator begin() const
{
- return const_iterator( m_List.begin(), m_List.end() );
+ return cbegin();
+ }
+ /// Returns a forward const iterator addressing the first element in a split-list
+ const_iterator cbegin() const
+ {
+ return const_iterator( m_List.cbegin(), m_List.cend() );
}
/// Returns an const iterator that addresses the location succeeding the last element in a split-list
const_iterator end() const
{
- return const_iterator( m_List.end(), m_List.end() );
+ return cend();
+ }
+ /// Returns an const iterator that addresses the location succeeding the last element in a split-list
+ const_iterator cend() const
+ {
+ return const_iterator( m_List.cend(), m_List.cend() );
}
};
{
return const_iterator( m_List.begin(), m_List.end() );
}
- const_iterator cbegin()
+ const_iterator cbegin() const
{
return const_iterator( m_List.cbegin(), m_List.cend() );
}
{
return const_iterator( m_List.end(), m_List.end() );
}
- const_iterator cend()
+ const_iterator cend() const
{
return const_iterator( m_List.cend(), m_List.cend() );
}
/// Returns a forward const iterator addressing the first element in a split-list
const_iterator begin() const
{
- return const_iterator( m_List.begin(), m_List.end() );
+ return cbegin();
+ }
+ /// Returns a forward const iterator addressing the first element in a split-list
+ const_iterator cbegin() const
+ {
+ return const_iterator( m_List.cbegin(), m_List.cend() );
}
/// Returns an const iterator that addresses the location succeeding the last element in a split-list
const_iterator end() const
{
- return const_iterator( m_List.end(), m_List.end() );
+ return cend();
+ }
+ /// Returns an const iterator that addresses the location succeeding the last element in a split-list
+ const_iterator cend() const
+ {
+ return const_iterator( m_List.cend(), m_List.cend() );
}
};
}
CPPUNIT_ASSERT( check_size( m, 500 ));
+ {
+ typename Map::iterator it( m.begin() );
+ typename Map::const_iterator cit( m.cbegin() );
+ CPPUNIT_CHECK( it == cit );
+ CPPUNIT_CHECK( it != m.end() );
+ CPPUNIT_CHECK( it != m.cend() );
+ CPPUNIT_CHECK( cit != m.end() );
+ CPPUNIT_CHECK( cit != m.cend() );
+ ++it;
+ CPPUNIT_CHECK( it != cit );
+ CPPUNIT_CHECK( it != m.end() );
+ CPPUNIT_CHECK( it != m.cend() );
+ CPPUNIT_CHECK( cit != m.end() );
+ CPPUNIT_CHECK( cit != m.cend() );
+ ++cit;
+ CPPUNIT_CHECK( it == cit );
+ CPPUNIT_CHECK( it != m.end() );
+ CPPUNIT_CHECK( it != m.cend() );
+ CPPUNIT_CHECK( cit != m.end() );
+ CPPUNIT_CHECK( cit != m.cend() );
+ }
+
+
for ( iterator it = m.begin(), itEnd = m.end(); it != itEnd; ++it ) {
+ iterator it2 = it;
+ CPPUNIT_CHECK( it2 == it );
+ CPPUNIT_CHECK( it2 == itEnd );
CPPUNIT_ASSERT( it->first * 2 == (*it).second.m_val );
it->second = it->first;
}
CPPUNIT_ASSERT( s.insert( i, i * 2 ));
}
+ {
+ typename Map::iterator it( s.begin() );
+ typename Map::const_iterator cit( s.cbegin() );
+ CPPUNIT_CHECK( it == cit );
+ CPPUNIT_CHECK( it != s.end() );
+ CPPUNIT_CHECK( it != s.cend() );
+ CPPUNIT_CHECK( cit != s.end() );
+ CPPUNIT_CHECK( cit != s.cend() );
+ ++it;
+ CPPUNIT_CHECK( it != cit );
+ CPPUNIT_CHECK( it != s.end() );
+ CPPUNIT_CHECK( it != s.cend() );
+ CPPUNIT_CHECK( cit != s.end() );
+ CPPUNIT_CHECK( cit != s.cend() );
+ ++cit;
+ CPPUNIT_CHECK( it == cit );
+ CPPUNIT_CHECK( it != s.end() );
+ CPPUNIT_CHECK( it != s.cend() );
+ CPPUNIT_CHECK( cit != s.end() );
+ CPPUNIT_CHECK( cit != s.cend() );
+ }
+
int nCount = 0;
for ( iterator it = s.begin(), itEnd = s.end(); it != itEnd; ++it ) {
CPPUNIT_ASSERT( it->first * 2 == it->second.m_val );
// Iterator test
{
typename OrdList::iterator it = l.begin();
+ typename OrdList::const_iterator cit = l.cbegin();
CPPUNIT_ASSERT( it != l.end() );
+ CPPUNIT_ASSERT( it != l.cend() );
+ CPPUNIT_ASSERT( cit != l.end() );
+ CPPUNIT_ASSERT( cit != l.cend() );
+ CPPUNIT_ASSERT( cit == it );
+
CPPUNIT_ASSERT( it->nKey == v2.nKey );
CPPUNIT_ASSERT( it->nVal == v2.nVal );
CPPUNIT_ASSERT( ++it != l.end() );
{
typename OrdList::iterator it = l.begin();
+ typename OrdList::const_iterator cit = l.cbegin();
CPPUNIT_ASSERT( it != l.end() );
+ CPPUNIT_ASSERT( it != l.cend() );
+ CPPUNIT_ASSERT( cit != l.end() );
+ CPPUNIT_ASSERT( cit != l.cend() );
+ CPPUNIT_ASSERT( cit == it );
+
CPPUNIT_ASSERT( it->nKey == v2.nKey );
CPPUNIT_ASSERT( it->nVal == v2.nVal );
CPPUNIT_ASSERT( ++it != l.end() );
// begin/end
{
typename OrdList::iterator it = l.begin();
+ typename OrdList::const_iterator cit = l.cbegin();
CPPUNIT_ASSERT( it != l.end() );
+ CPPUNIT_ASSERT( it != l.cend() );
+ CPPUNIT_ASSERT( cit != l.end() );
+ CPPUNIT_ASSERT( cit != l.cend() );
+ CPPUNIT_ASSERT( cit == it );
+
CPPUNIT_ASSERT( it->nKey == v2.nKey );
CPPUNIT_ASSERT( it->nVal == v2.nVal );
CPPUNIT_ASSERT( ++it != l.end() );
{
typename OrdList::iterator it = l.begin();
+ typename OrdList::const_iterator cit = l.cbegin();
CPPUNIT_ASSERT( it != l.end() );
+ CPPUNIT_ASSERT( it != l.cend() );
+ CPPUNIT_ASSERT( cit != l.end() );
+ CPPUNIT_ASSERT( cit != l.cend() );
+ CPPUNIT_ASSERT( cit == it );
+
CPPUNIT_ASSERT( it->nKey == v2.nKey );
CPPUNIT_ASSERT( it->nVal == v2.nVal );
CPPUNIT_ASSERT( ++it != l.end() );
{
int nCount = 100;
for ( int i = 0; i < nCount; ++i )
- CPPUNIT_ASSERT( l.insert(i) );
+ CPPUNIT_ASSERT( l.insert( i ) );
+
+ {
+ 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->nKey == 1001 );
CPPUNIT_ASSERT( it->nVal == 1001 * 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() );
+ }
+
+
l.clear();
CPPUNIT_ASSERT( l.empty() );
}
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 );
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 );
for ( int i = 0; i < nCount; ++i )
CPPUNIT_ASSERT( l.insert(i) );
+ {
+ 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 ) {
it->nVal = i * 2;
CPPUNIT_ASSERT( it->nKey == 1001 );
CPPUNIT_ASSERT( it->nVal == 1001 * 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() );
+ }
+
+
l.clear();
CPPUNIT_ASSERT( l.empty() );
}
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 );
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 );
CPPUNIT_ASSERT( s.insert( v[i] ));
}
+ {
+ typename Set::iterator it( s.begin() );
+ typename Set::const_iterator cit( s.cbegin() );
+ CPPUNIT_CHECK( it == cit );
+ CPPUNIT_CHECK( it != s.end() );
+ CPPUNIT_CHECK( it != s.cend() );
+ CPPUNIT_CHECK( cit != s.end() );
+ CPPUNIT_CHECK( cit != s.cend() );
+ ++it;
+ CPPUNIT_CHECK( it != cit );
+ CPPUNIT_CHECK( it != s.end() );
+ CPPUNIT_CHECK( it != s.cend() );
+ CPPUNIT_CHECK( cit != s.end() );
+ CPPUNIT_CHECK( cit != s.cend() );
+ ++cit;
+ CPPUNIT_CHECK( it == cit );
+ CPPUNIT_CHECK( it != s.end() );
+ CPPUNIT_CHECK( it != s.cend() );
+ CPPUNIT_CHECK( cit != s.end() );
+ CPPUNIT_CHECK( cit != s.cend() );
+ }
+
int nCount = 0;
for ( set_iterator it = s.begin(), itEnd = s.end(); it != itEnd; ++it ) {
+ set_iterator it2 = it;
+ CPPUNIT_CHECK( it == it2 );
+ CPPUNIT_CHECK( it2 != itEnd );
CPPUNIT_ASSERT( (*it).nKey * 2 == it->nVal );
it->nVal = (*it).nKey;
++nCount;
CPPUNIT_ASSERT( s.insert( std::make_pair( i, i * 2) ) != s.end() );
}
for ( iterator it = s.begin(), itEnd = s.end(); it != itEnd; ++it ) {
+ iterator it2 = it;
+ CPPUNIT_CHECK( it2 == it );
+ CPPUNIT_CHECK( it2 != itEnd );
CPPUNIT_ASSERT( (*it).nKey * 2 == it->nVal );
it->nVal = (*it).nKey;
}
for ( int i = 0; size_t(i) < nMaxCount; ++i ) {
CPPUNIT_ASSERT( s.insert( std::make_pair( i, i * 2) ));
}
+
+ {
+ typename Set::iterator it( s.begin() );
+ typename Set::const_iterator cit( s.cbegin() );
+ CPPUNIT_CHECK( it == cit );
+ CPPUNIT_CHECK( it != s.end() );
+ CPPUNIT_CHECK( it != s.cend() );
+ CPPUNIT_CHECK( cit != s.end() );
+ CPPUNIT_CHECK( cit != s.cend() );
+ ++it;
+ CPPUNIT_CHECK( it != cit );
+ CPPUNIT_CHECK( it != s.end() );
+ CPPUNIT_CHECK( it != s.cend() );
+ CPPUNIT_CHECK( cit != s.end() );
+ CPPUNIT_CHECK( cit != s.cend() );
+ ++cit;
+ CPPUNIT_CHECK( it == cit );
+ CPPUNIT_CHECK( it != s.end() );
+ CPPUNIT_CHECK( it != s.cend() );
+ CPPUNIT_CHECK( cit != s.end() );
+ CPPUNIT_CHECK( cit != s.cend() );
+ }
+
size_t nCount = 0;
for ( iterator it = s.begin(), itEnd = s.end(); it != itEnd; ++it ) {
CPPUNIT_ASSERT_EX( (*it).nKey * 2 == it->nVal,
std::random_shuffle( m_Arr.begin(), m_Arr.end() );
}
+ template <typename Iterator, typename Map>
+ static bool check_result( Iterator const& it, Map const& map )
+ {
+ return it != map.end();
+ }
+ template <typename Map>
+ static bool check_result( bool b, Map const& )
+ {
+ return b;
+ }
+
template <class Map>
class TestThread: public CppUnitMini::TestThread
{
if ( m_nThreadNo & 1 ) {
ValueVector::const_iterator itEnd = arr.end();
for ( ValueVector::const_iterator it = arr.begin(); it != itEnd; ++it ) {
- bool bFound = rMap.find( it->nKey );
+ auto bFound = rMap.find( it->nKey );
if ( it->bExists ) {
- if ( bFound )
+ if ( check_result( bFound, rMap ))
++m_KeyExists.nSuccess;
else {
//rMap.find( it->nKey );
}
}
else {
- if ( bFound ) {
+ if ( check_result( bFound, rMap )) {
//rMap.find( it->nKey );
++m_KeyNotExists.nFailed;
}
else {
ValueVector::const_reverse_iterator itEnd = arr.rend();
for ( ValueVector::const_reverse_iterator it = arr.rbegin(); it != itEnd; ++it ) {
- bool bFound = rMap.find( it->nKey );
+ auto bFound = rMap.find( it->nKey );
if ( it->bExists ) {
- if ( bFound )
+ if ( check_result( bFound, rMap ))
++m_KeyExists.nSuccess;
else {
//rMap.find( it->nKey );
}
}
else {
- if ( bFound ) {
+ if ( check_result( bFound, rMap )) {
//rMap.find( it->nKey );
++m_KeyNotExists.nFailed;
}
timer.reset();
for ( size_t i = 0; i < m_Arr.size(); ++i ) {
if ( m_Arr[i].bExists ) {
- CPPUNIT_ASSERT( testMap.insert( m_Arr[i].nKey, m_Arr[i] ) );
+ CPPUNIT_ASSERT( check_result( testMap.insert( m_Arr[i].nKey, m_Arr[i] ), testMap ));
}
}
CPPUNIT_MSG( " Duration=" << timer.duration() );
// find int test in map<int> in mutithreaded mode
namespace map2 {
-# define TEST_MAP(X) void X() { test<MapTypes<key_type, value_type>::X >() ; }
-# define TEST_MAP_NOLF(X) void X() { test_nolf<MapTypes<key_type, value_type>::X >() ; }
+# define TEST_MAP(X) void X() { test<MapTypes<key_type, value_type>::X >() ; }
+# define TEST_MAP_NOLF(X) void X() { test_nolf<MapTypes<key_type, value_type>::X >() ; }
# define TEST_MAP_EXTRACT(X) TEST_MAP(X)
# define TEST_MAP_NOLF_EXTRACT(X) TEST_MAP_NOLF(X)
size_t m_nRealMapSize;
bool m_bSeqInit;
+ template <typename Iterator, typename Map>
+ static bool check_result( Iterator const& it, Map const& map )
+ {
+ return it != map.end();
+ }
+ template <typename Map>
+ static bool check_result( bool b, Map const& )
+ {
+ return b;
+ }
+
template <class MAP>
class TestThread: public CppUnitMini::TestThread
{
if ( m_nThreadNo & 1 ) {
ValueVector::const_iterator itEnd = arr.end();
for ( ValueVector::const_iterator it = arr.begin(); it != itEnd; ++it ) {
- bool bFound = rMap.find( *(it->pKey) );
+ auto bFound = rMap.find( *(it->pKey) );
if ( it->bExists ) {
- if ( bFound )
+ if ( check_result(bFound, rMap))
++m_KeyExists.nSuccess;
else
++m_KeyExists.nFailed;
}
else {
- if ( bFound )
+ if ( check_result(bFound, rMap))
++m_KeyNotExists.nFailed;
else
++m_KeyNotExists.nSuccess;
else {
ValueVector::const_reverse_iterator itEnd = arr.rend();
for ( ValueVector::const_reverse_iterator it = arr.rbegin(); it != itEnd; ++it ) {
- bool bFound = rMap.find( *(it->pKey) );
+ auto bFound = rMap.find( *(it->pKey) );
if ( it->bExists ) {
- if ( bFound )
+ if ( check_result(bFound, rMap))
++m_KeyExists.nSuccess;
else
++m_KeyExists.nFailed;
}
else {
- if ( bFound )
+ if ( check_result( bFound, rMap ))
++m_KeyNotExists.nFailed;
else
++m_KeyNotExists.nSuccess;
for ( size_t i = 0; i < m_Arr.size(); ++i ) {
// Âñå êëþ÷è â arrData - óíèêàëüíûå, ïîýòîìó îøèáîê ïðè âñòàâêå áûòü íå äîëæíî
if ( m_Arr[i].bExists )
- CPPUNIT_ASSERT( testMap.insert( *(m_Arr[i].pKey), m_Arr[i] ) );
+ CPPUNIT_ASSERT( check_result( testMap.insert( *(m_Arr[i].pKey), m_Arr[i] ), testMap ));
}
CPPUNIT_MSG( " Duration=" << timer.duration() );
typedef size_t key_type;
typedef size_t value_type;
+ template <typename Iterator, typename Map>
+ static bool check_result( Iterator const& it, Map const& map )
+ {
+ return it != map.end();
+ }
+ template <typename Map>
+ static bool check_result( bool b, Map const& )
+ {
+ return b;
+ }
+
template <class Map>
class Inserter: public CppUnitMini::TestThread
{
size_t const nArrSize = m_arrVal.size();
for ( size_t i = 0; i < nArrSize; ++i ) {
size_t const nItem = m_arrVal[i];
- if ( rMap.insert( nItem, nItem * 8 ) )
+ if ( check_result( rMap.insert( nItem, nItem * 8 ), rMap ))
++m_nInsertSuccess;
else
++m_nInsertFailed;
for ( size_t k = 0; k <= i; ++k ) {
- if ( rMap.find( m_arrVal[k] ) )
+ if ( check_result( rMap.find( m_arrVal[k] ), rMap ))
++m_nFindSuccess;
else
++m_nFindFail;