CxxUtils::ArrayIterator< N > Class Template Reference

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

#include <Array.h>

List of all members.

Classes

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

Public Types

typedef std::iterator
< std::random_access_iterator_tag,
const Array< N-1 > > 
base_iterator
 Shorthand for the base class.
typedef
base_iterator::iterator_category 
iterator_category
 Standard iterator_category typedef, from the base class.
typedef base_iterator::value_type value_type
 Standard value_type typedef, from the base class.
typedef
base_iterator::difference_type 
difference_type
 Standard difference typedef, from the base class.
typedef base_iterator::reference reference
 Standard reference typedef, from the base class.

Public Member Functions

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

Detailed Description

template<unsigned int N>
class CxxUtils::ArrayIterator< N >

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.


Constructor & Destructor Documentation

template<unsigned int N>
CxxUtils::ArrayIterator< N >::ArrayIterator ( const Arrayrep rep,
unsigned int  offs 
) [inline]

Constructor from Arrayrep and offset.

Parameters:
rep The underlying array representation.
offs The offset in the representation of the first element referenced by this iterator.

Member Function Documentation

template<unsigned int N>
bool CxxUtils::ArrayIterator< N >::operator!= ( const ArrayIterator< N > &  other  )  const [inline]

Inequality comparison.

Parameters:
other The other object with which to compare.
Returns:
True if the iterators are not equal.
template<unsigned int N>
ArrayIterator< N >::value_type CxxUtils::ArrayIterator< N >::operator* (  )  const [inline]

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.)
template<unsigned int N>
ArrayIterator< N > CxxUtils::ArrayIterator< N >::operator+ ( difference_type  n  )  const [inline]

Return a new iterator pointing n steps ahead.

Parameters:
n Number of steps by which to advance.
Returns:
The new iterator.
template<unsigned int N>
ArrayIterator< N > CxxUtils::ArrayIterator< N >::operator++ ( int   )  [inline]

Advance the iterator.

Returns:
The iterator before being advanced.
template<unsigned int N>
ArrayIterator< N > & CxxUtils::ArrayIterator< N >::operator++ (  )  [inline]

Advance the iterator.

Returns:
This iterator.
template<unsigned int N>
ArrayIterator< N > & CxxUtils::ArrayIterator< N >::operator+= ( difference_type  n  )  [inline]

Advance the iterator.

Parameters:
n Number of steps by which to advance the iterator.
Returns:
This iterator.
template<unsigned int N>
ArrayIterator< N >::difference_type CxxUtils::ArrayIterator< N >::operator- ( const ArrayIterator< N > &  other  )  const [inline]

Return the difference between two iterators.

Parameters:
other The 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.
template<unsigned int N>
ArrayIterator< N > CxxUtils::ArrayIterator< N >::operator- ( difference_type  n  )  const [inline]

Return a new iterator pointing n steps behind.

Parameters:
n Number of steps by which to back up.
Returns:
The new iterator.
template<unsigned int N>
ArrayIterator< N > CxxUtils::ArrayIterator< N >::operator-- ( int   )  [inline]

Back up the iterator.

Returns:
The iterator before being backed up.
template<unsigned int N>
ArrayIterator< N > & CxxUtils::ArrayIterator< N >::operator-- (  )  [inline]

Back up the iterator.

Returns:
This iterator.
template<unsigned int N>
ArrayIterator< N > & CxxUtils::ArrayIterator< N >::operator-= ( difference_type  n  )  [inline]

Back up the iterator.

Parameters:
n Number of steps by which to advance the iterator.
Returns:
This iterator.
template<unsigned int N>
ArrayIterator< N >::pointer CxxUtils::ArrayIterator< N >::operator-> (  )  const [inline]

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.

template<unsigned int N>
bool CxxUtils::ArrayIterator< N >::operator< ( const ArrayIterator< N > &  other  )  const [inline]

Less-than comparison.

Parameters:
other The 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.
template<unsigned int N>
bool CxxUtils::ArrayIterator< N >::operator<= ( const ArrayIterator< N > &  other  )  const [inline]

Less-than-or-equal comparison.

Parameters:
other The 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.
template<unsigned int N>
bool CxxUtils::ArrayIterator< N >::operator== ( const ArrayIterator< N > &  other  )  const [inline]

Equality comparison.

Parameters:
other The other object with which to compare.
Returns:
True if the iterators are equal.
template<unsigned int N>
bool CxxUtils::ArrayIterator< N >::operator> ( const ArrayIterator< N > &  other  )  const [inline]

Greater-than comparison.

Parameters:
other The 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.
template<unsigned int N>
bool CxxUtils::ArrayIterator< N >::operator>= ( const ArrayIterator< N > &  other  )  const [inline]

Greater-than-or-equal comparison.

Parameters:
other The 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.
template<unsigned int N>
ArrayIterator< N >::value_type CxxUtils::ArrayIterator< N >::operator[] ( difference_type  n  )  const [inline]

Array indexing relative to the iterator.

Parameters:
n The 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.)

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 1 Dec 2017 for RootCore Packages by  doxygen 1.6.1