reverse_iterator Class

class reverse_iterator: public const_reverse_iterator

The reverse_iterator templated class is an STL-like iterator that can be instantiated and attached to any collection that implements the  ITraversableT templated interface. Unlike STL's iterators, reverse_iterator is polymorphic, meaning it can traverse a collection without explicit knowledge of the collection's type. reverse_iterator is a bidirectional type iterator that is interface compatible with its STL counterpart. Therefore, it can be used with any STL algorithm which takes a bidirectional iterator. Note, reverse_iterator does not support random iteration.

Defined in: PolyIter.h

Class Template Arguments

_Ty

The type of element in the collection the iterator is traversing.

Member functions include: reverse_iteratorbeginendat_beginat_endoperator*operator-> operator++ operator++operator--operator--operator==operator!=operator=

Class Members

reverse_iterator(typename qualified_traversable_type* pt)

Constructs a reverse_iterator and attaches it to the specified traversable

reverse_iterator(typename const reverse_iterator&lttypename _Ty>& iter )

Copy constructor for const_iterator

void prev()

Move the iterator to the previous element in the collection

void next()

Move the iterator to the next element in the collection

typename const_reference getref() const

Return a const reference to the element at the iterator's current position

typename const_pointer getptr() const

Return a const pointer to the element at the iterator's current position

void begin()

Positions the iterator at the start of the collection, which for a reverse is actually at the physical last element.

void end()

Positions the iterator at the end of the collection. Note, the end is one passed the last element.

bool at_begin() const

Returns true if currently positioned at start of the collection

bool at_end() const

Returns true if currently positioned at end of collection

typename reference operator*() const

Returns a reference to the element at the current iterator position

typename pointer operator->() const

Returns a pointer to the element at the current iterator position

typename reverse_iterator& operator++()

The preincrement operator advances the iterator by one position and returns *this

typename reverse_iterator operator++(int)

The postincrement operator advances the iterator by one position and returns an unmoved *this

typename reverse_iterator& operator--()

The predecrement operator retreats the iterator by one position and returns *this

typename reverse_iterator operator--(int)

The predecrement operator retreats the iterator by one position and returns an unmoved *this

const_attach(iter.m_pct)

This iterator is set equal to the given one