ATLAS Offline Software
Classes | Public Types | Public Member Functions | Private Attributes | List of all members
CxxUtils::ArrayIterator Class Reference

Iterator class for Array<N>. More...

#include <Array.h>

Collaboration diagram for CxxUtils::ArrayIterator:

Classes

class  pointer
 Proxy to return from operator>. More...
 

Public Types

using iterator_category = std::random_access_iterator_tag
 
using value_type = const Array< N-1 >
 
using difference_type = std::ptrdiff_t
 
using reference = value_type &
 

Public Member Functions

 ArrayIterator ()
 Default constructor. More...
 
 ArrayIterator (const Arrayrep *rep, unsigned int offs)
 Constructor from Arrayrep and offset. More...
 
bool operator== (const ArrayIterator &other) const
 Equality comparison. More...
 
bool operator!= (const ArrayIterator &other) const
 Inequality comparison. More...
 
bool operator< (const ArrayIterator &other) const
 Less-than comparison. More...
 
bool operator> (const ArrayIterator &other) const
 Greater-than comparison. More...
 
bool operator<= (const ArrayIterator &other) const
 Less-than-or-equal comparison. More...
 
bool operator>= (const ArrayIterator &other) const
 Greater-than-or-equal comparison. More...
 
value_type operator* () const
 Dereference the iterator. More...
 
pointer operator-> () const
 Dereference the iterator. More...
 
ArrayIterator< N > & operator++ ()
 Advance the iterator. More...
 
ArrayIterator< N > operator++ (int)
 Advance the iterator. More...
 
ArrayIterator< N > & operator-- ()
 Back up the iterator. More...
 
ArrayIterator< N > operator-- (int)
 Back up the iterator. More...
 
value_type operator[] (difference_type n) const
 Array indexing relative to the iterator. More...
 
ArrayIterator< N > & operator+= (difference_type n)
 Advance the iterator. More...
 
ArrayIterator< N > operator+ (difference_type n) const
 Return a new iterator pointing n steps ahead. More...
 
ArrayIterator< N > & operator-= (difference_type n)
 Back up the iterator. More...
 
ArrayIterator< N > operator- (difference_type n) const
 Return a new iterator pointing n steps behind. More...
 
difference_type operator- (const ArrayIterator &other) const
 Return the difference between two iterators. More...
 

Private Attributes

const Arrayrepm_rep
 The underlying array representation. More...
 
unsigned int m_offs
 Offset into the representation's data array of the first element referred to by this iterator. More...
 

Detailed Description

Iterator class for Array<N>.

This serves as an iterator class for Array<N>, where N >= 2. It gives a Array<N-1> as value_type. Only const access is supported.

This class is almost, but not quite, a random access iterator. operator* and operator[] returns a value_type instead of a reference. And operator-> returns a proxy. (The issues here are similar to those encountered with std::vector<bool>.) But it should mostly work as you expect.

Definition at line 51 of file Control/CxxUtils/CxxUtils/Array.h.

Member Typedef Documentation

◆ difference_type

Definition at line 399 of file Control/CxxUtils/CxxUtils/Array.h.

◆ iterator_category

using CxxUtils::ArrayIterator::iterator_category = std::random_access_iterator_tag

Definition at line 397 of file Control/CxxUtils/CxxUtils/Array.h.

◆ reference

Definition at line 400 of file Control/CxxUtils/CxxUtils/Array.h.

◆ value_type

Definition at line 398 of file Control/CxxUtils/CxxUtils/Array.h.

Constructor & Destructor Documentation

◆ ArrayIterator() [1/2]

CxxUtils::ArrayIterator::ArrayIterator ( )

Default constructor.

Makes an invalid iterator.

◆ ArrayIterator() [2/2]

CxxUtils::ArrayIterator::ArrayIterator ( const Arrayrep rep,
unsigned int  offs 
)

Constructor from Arrayrep and offset.

Parameters
repThe underlying array representation.
offsThe offset in the representation of the first element referenced by this iterator.

Member Function Documentation

◆ operator!=()

Inequality comparison.

Parameters
otherThe other object with which to compare.
Returns
True if the iterators are not equal.

◆ operator*()

value_type CxxUtils::ArrayIterator::operator* ( ) const

Dereference the iterator.

Returns
The value that the iterator points to. Note that this method returns a value_type, not a reference. (Thus, this class does not quite conform to the iterator requirements.)

◆ operator+()

ArrayIterator<N> CxxUtils::ArrayIterator::operator+ ( difference_type  n) const

Return a new iterator pointing n steps ahead.

Parameters
nNumber of steps by which to advance.
Returns
The new iterator.

◆ operator++() [1/2]

ArrayIterator<N>& CxxUtils::ArrayIterator::operator++ ( )

Advance the iterator.

Returns
This iterator.

◆ operator++() [2/2]

ArrayIterator<N> CxxUtils::ArrayIterator::operator++ ( int  )

Advance the iterator.

Returns
The iterator before being advanced.

◆ operator+=()

ArrayIterator<N>& CxxUtils::ArrayIterator::operator+= ( difference_type  n)

Advance the iterator.

Parameters
nNumber of steps by which to advance the iterator.
Returns
This iterator.

◆ operator-() [1/2]

difference_type CxxUtils::ArrayIterator::operator- ( const ArrayIterator other) const

Return the difference between two iterators.

Parameters
otherThe other iterator for the comparison.
Returns
The number of elements difference between this iterator and other. Undefined if the two iterators do not point into the same array.

◆ operator-() [2/2]

ArrayIterator<N> CxxUtils::ArrayIterator::operator- ( difference_type  n) const

Return a new iterator pointing n steps behind.

Parameters
nNumber of steps by which to back up.
Returns
The new iterator.

◆ operator--() [1/2]

ArrayIterator<N>& CxxUtils::ArrayIterator::operator-- ( )

Back up the iterator.

Returns
This iterator.

◆ operator--() [2/2]

ArrayIterator<N> CxxUtils::ArrayIterator::operator-- ( int  )

Back up the iterator.

Returns
The iterator before being backed up.

◆ operator-=()

ArrayIterator<N>& CxxUtils::ArrayIterator::operator-= ( difference_type  n)

Back up the iterator.

Parameters
nNumber of steps by which to advance the iterator.
Returns
This iterator.

◆ operator->()

pointer CxxUtils::ArrayIterator::operator-> ( ) const

Dereference the iterator.

Returns
A proxy for the iterator element.

This method will return a proxy for the array, which you can then dereference. Note that if you get a C++ pointer from this, then it will be valid only until the proxy object gets destroyed.

◆ operator<()

bool CxxUtils::ArrayIterator::operator< ( const ArrayIterator other) const

Less-than comparison.

Parameters
otherThe other object with which to compare.
Returns
True if this iterator is less than other. This will always return false for iterators over different arrays.

◆ operator<=()

bool CxxUtils::ArrayIterator::operator<= ( const ArrayIterator other) const

Less-than-or-equal comparison.

Parameters
otherThe other object with which to compare.
Returns
True if this iterator is less than or equal to other. This will always return false for iterators over different arrays.

◆ operator==()

bool CxxUtils::ArrayIterator::operator== ( const ArrayIterator other) const

Equality comparison.

Parameters
otherThe other object with which to compare.
Returns
True if the iterators are equal.

◆ operator>()

bool CxxUtils::ArrayIterator::operator> ( const ArrayIterator other) const

Greater-than comparison.

Parameters
otherThe other object with which to compare.
Returns
True if this iterator is greater than other. This will always return false for iterators over different arrays.

◆ operator>=()

bool CxxUtils::ArrayIterator::operator>= ( const ArrayIterator other) const

Greater-than-or-equal comparison.

Parameters
otherThe other object with which to compare.
Returns
True if this iterator is less than or equal to other. This will always return false for iterators over different arrays.

◆ operator[]()

value_type CxxUtils::ArrayIterator::operator[] ( difference_type  n) const

Array indexing relative to the iterator.

Parameters
nThe array index.
Returns
The array item at an offset of n from the current iterator position. Note that this method returns a value_type, not a reference. (Thus, this class does not quite conform to the iterator requirements.)

Member Data Documentation

◆ m_offs

unsigned int CxxUtils::ArrayIterator::m_offs
private

Offset into the representation's data array of the first element referred to by this iterator.

Definition at line 633 of file Control/CxxUtils/CxxUtils/Array.h.

◆ m_rep

const Arrayrep* CxxUtils::ArrayIterator::m_rep
private

The underlying array representation.

Definition at line 629 of file Control/CxxUtils/CxxUtils/Array.h.


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