ATLAS Offline Software
Loading...
Searching...
No Matches
CxxUtils::const_iterator Class Reference

Iterator over all 1 bits in the set. More...

#include <ConcurrentBitset.h>

Inheritance diagram for CxxUtils::const_iterator:
Collaboration diagram for CxxUtils::const_iterator:

Public Types

typedef std::forward_iterator_tag iterator_category
typedef size_t value_type
typedef ptrdiff_t difference_type
typedef const value_typepointer
typedef const value_typereference

Public Member Functions

bit_t operator* () const
 Return the bit number which the iterator is currently referencing.
const_iteratoroperator++ ()
 Advance the iterator to the next set bit (preincrement).
const_iterator operator++ (int)
 Advance the iterator to the next set bit (postincrement).
bool operator== (const const_iterator &other) const
 Compare two iterators.
bool operator!= (const const_iterator &other) const
 Compare two iterators.
 const_iterator (typename Impl_t::const_iterator it)
 Constructor.
bool valid () const
 Test if this iterator is valid.
 const_iterator (typename Impl_t::const_iterator it)
 Constructor.
 const_iterator (const iterator &other)
 Conversion from non-const iterator (for interoperability).
bool valid () const
 Test if this iterator is valid.

Private Member Functions

 const_iterator (Block_t cache, bit_t bit, const std::atomic< Block_t > *data, const std::atomic< Block_t > *end)
 Constructor.
void increment ()
 iterator_facade requirement: Increment the iterator.
void decrement ()
 iterator_facade requirement: Decrement the iterator.
bool equal (const const_iterator &other) const
 iterator_facade requirement: Equality test.
const const_iterator_value dereference () const
 iterator_facade requirement: Dereference the iterator.
void increment ()
 iterator_facade requirement: Increment the iterator.
void decrement ()
 iterator_facade requirement: Decrement the iterator.
bool equal (const const_iterator &other) const
 iterator_facade requirement: Equality test.
bool equal (const iterator &other) const
 iterator_facade requirement: Equality test.
const const_iterator_value dereference () const
 iterator_facade requirement: Dereference the iterator.

Private Attributes

friend ConcurrentBitset
Block_t m_cache
 Cache of the block to which we're currently pointing. Should be shifted such that the bit we're referencing has just been shifted off the right.
bit_t m_bit
 Bit number which we're currently referencing.
const std::atomic< Block_t > * m_data
 Pointer to the block containing the bit which we're currently referencing.
const std::atomic< Block_t > * m_end
 Pointer to one past the last block in the set.
Impl_t::const_iterator m_impl
 The iterator on the underlying table.

Friends

class boost::iterator_core_access
 Required by iterator_facade.
class iterator

Detailed Description

Iterator over all 1 bits in the set.

Const iterator class.

Iterator class.

This iterator will visit all 1 bits in the set (that is, it works like the iterator for a set<bit_t>). The state of an iterator consists of:

  • m_bit – The number of the current bit we're referencing.
  • m_data – Pointer to the current block we're referencing.
  • m_cache – Cached value of the current block. This is shifted such that the referenced bit has just fallen off the right.
  • m_end – Pointer to one past the last block we should consider in the iteration. (This may be less than the full size of the set if we know that the end of the set is all 0's. This is tracked by Impl::m_hwm.)

The end iterator is marked by setting m_bit to -1; none of the other fields matter in that case. Thus, we can compare iterators by simply comparing m_bit.

To initialize an iterator in begin(), we set the iterator to point to the block preceding the first block of the set, with the cache set to 0. We can then use the increment operator to advance the iterator to the first 1 bit.

This uses boost::iterator_facade to define the methods required by an STL iterator in terms of the private methods below.

Since dereference() will be returning a const_iterator_value by value, we also need to override the reference type.

Definition at line 693 of file ConcurrentBitset.h.

Member Typedef Documentation

◆ difference_type

typedef ptrdiff_t CxxUtils::const_iterator::difference_type

Definition at line 697 of file ConcurrentBitset.h.

◆ iterator_category

typedef std::forward_iterator_tag CxxUtils::const_iterator::iterator_category

Definition at line 695 of file ConcurrentBitset.h.

◆ pointer

typedef const value_type* CxxUtils::const_iterator::pointer

Definition at line 698 of file ConcurrentBitset.h.

◆ reference

typedef const value_type& CxxUtils::const_iterator::reference

Definition at line 699 of file ConcurrentBitset.h.

◆ value_type

typedef size_t CxxUtils::const_iterator::value_type

Definition at line 696 of file ConcurrentBitset.h.

Constructor & Destructor Documentation

◆ const_iterator() [1/4]

CxxUtils::const_iterator::const_iterator ( Block_t cache,
bit_t bit,
const std::atomic< Block_t > * data,
const std::atomic< Block_t > * end )
private

Constructor.

Parameters
cacheCached block at the current iteration point, shifted such that bit number bit has just been shifted off the right.
bitBit number the at which the iterator is currently pointing.
dataPointer to the block at which the iterator is currently pointing.
endOne past the last block of the iteration range.

◆ const_iterator() [2/4]

CxxUtils::const_iterator::const_iterator ( typename Impl_t::const_iterator it)

Constructor.

Parameters
itIterator of the underlying table.

◆ const_iterator() [3/4]

CxxUtils::const_iterator::const_iterator ( typename Impl_t::const_iterator it)

Constructor.

Parameters
itIterator of the underlying table.

◆ const_iterator() [4/4]

CxxUtils::const_iterator::const_iterator ( const iterator & other)

Conversion from non-const iterator (for interoperability).

Parameters
otherThe other iterator.

Member Function Documentation

◆ decrement() [1/2]

void CxxUtils::const_iterator::decrement ( )
private

iterator_facade requirement: Decrement the iterator.

◆ decrement() [2/2]

void CxxUtils::const_iterator::decrement ( )
private

iterator_facade requirement: Decrement the iterator.

◆ dereference() [1/2]

const const_iterator_value CxxUtils::const_iterator::dereference ( ) const
private

iterator_facade requirement: Dereference the iterator.

◆ dereference() [2/2]

const const_iterator_value CxxUtils::const_iterator::dereference ( ) const
private

iterator_facade requirement: Dereference the iterator.

◆ equal() [1/3]

bool CxxUtils::const_iterator::equal ( const const_iterator & other) const
private

iterator_facade requirement: Equality test.

◆ equal() [2/3]

bool CxxUtils::const_iterator::equal ( const const_iterator & other) const
private

iterator_facade requirement: Equality test.

◆ equal() [3/3]

bool CxxUtils::const_iterator::equal ( const iterator & other) const
private

iterator_facade requirement: Equality test.

(Interoperability.)

◆ increment() [1/2]

void CxxUtils::const_iterator::increment ( )
private

iterator_facade requirement: Increment the iterator.

◆ increment() [2/2]

void CxxUtils::const_iterator::increment ( )
private

iterator_facade requirement: Increment the iterator.

◆ operator!=()

bool CxxUtils::const_iterator::operator!= ( const const_iterator & other) const

Compare two iterators.

Parameters
otherThe other iterator to compare.

◆ operator*()

bit_t CxxUtils::const_iterator::operator* ( ) const

Return the bit number which the iterator is currently referencing.

◆ operator++() [1/2]

const_iterator & CxxUtils::const_iterator::operator++ ( )

Advance the iterator to the next set bit (preincrement).

◆ operator++() [2/2]

const_iterator CxxUtils::const_iterator::operator++ ( int )

Advance the iterator to the next set bit (postincrement).

◆ operator==()

bool CxxUtils::const_iterator::operator== ( const const_iterator & other) const

Compare two iterators.

Parameters
otherThe other iterator to compare.

◆ valid() [1/2]

bool CxxUtils::const_iterator::valid ( ) const

Test if this iterator is valid.

This should be the same as testing for != end().

◆ valid() [2/2]

bool CxxUtils::const_iterator::valid ( ) const

Test if this iterator is valid.

This should be the same as testing for != end().

◆ boost::iterator_core_access

boost::iterator_core_access
friend

Required by iterator_facade.

Definition at line 272 of file ConcurrentMap.h.

◆ iterator

friend class iterator
friend

Definition at line 284 of file ConcurrentToValMap.h.

Member Data Documentation

◆ ConcurrentBitset

friend CxxUtils::const_iterator::ConcurrentBitset
private

Definition at line 703 of file ConcurrentBitset.h.

◆ m_bit

bit_t CxxUtils::const_iterator::m_bit
private

Bit number which we're currently referencing.

Definition at line 760 of file ConcurrentBitset.h.

◆ m_cache

Block_t CxxUtils::const_iterator::m_cache
private

Cache of the block to which we're currently pointing. Should be shifted such that the bit we're referencing has just been shifted off the right.

Definition at line 757 of file ConcurrentBitset.h.

◆ m_data

const std::atomic<Block_t>* CxxUtils::const_iterator::m_data
private

Pointer to the block containing the bit which we're currently referencing.

Definition at line 763 of file ConcurrentBitset.h.

◆ m_end

const std::atomic<Block_t>* CxxUtils::const_iterator::m_end
private

Pointer to one past the last block in the set.

Definition at line 767 of file ConcurrentBitset.h.

◆ m_impl

Impl_t::const_iterator CxxUtils::const_iterator::m_impl
private

The iterator on the underlying table.

Definition at line 300 of file ConcurrentMap.h.


The documentation for this class was generated from the following files: