Qx v0.5.8
Qt Extensions Library
|
The Traverser template class provides a const_iterator wrapper for an alternate approach to iterating over a type. More...
#include <qx/core/qx-traverser.h>
Public Member Functions | |
Traverser (const T &traverseable) | |
void | advance (quint32 count=1) |
bool | atEnd () const |
quint32 | currentIndex () const |
std::iter_value_t< typename T::const_iterator > | currentValue () const |
std::iter_value_t< typename T::const_iterator > | lookAhead (quint32 count=1) const |
std::iter_value_t< typename T::const_iterator > | lookBehind (quint32 count=1) const |
void | retreat (quint32 count=1) |
A traverser acts as an interface for iterating over a traversable type using more functional semantics instead of directly manipulating an iterator via operators.
Like with regular iterators, the end position of a traverser is an imaginary element one position further than the last.
|
inline |
Creates an traverser for iterating over traverseable, initialized to the beginning.
|
inline |
Advances the traverser count elements, stopping at the end if it is reached.
|
inline |
Reverses true
if the traverser is at the end of the traversable; otherwise, returns false
.
|
inline |
Returns the traverser's current position as an index.
|
inline |
Returns the value at the traverser's current position.
|
inline |
Returns the value at the position count ahead of the traverser's current position if that position is valid; otherwise returns a default-constructed value.
|
inline |
Returns the value at the position count behind of the traverser's current position if that position is valid; otherwise returns a default-constructed value.
|
inline |
Reverses the traverser count elements, stopping at the beginning if it is reached.