Qx v0.5.7
Qt Extensions Library
Loading...
Searching...
No Matches
Qx::Traverser< T > Class Template Reference

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)
 

Detailed Description

template<typename T>
requires traverseable<T>
class Qx::Traverser< T >

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.

Constructor & Destructor Documentation

◆ Traverser()

template<typename T >
Qx::Traverser< T >::Traverser ( const T & traverseable)
inline

Creates an traverser for iterating over traverseable, initialized to the beginning.

Member Function Documentation

◆ advance()

template<typename T >
void Qx::Traverser< T >::advance ( quint32 count = 1)
inline

Advances the traverser count elements, stopping at the end if it is reached.

◆ atEnd()

template<typename T >
bool Qx::Traverser< T >::atEnd ( ) const
inline

Reverses true if the traverser is at the end of the traversable; otherwise, returns false.

◆ currentIndex()

template<typename T >
quint32 Qx::Traverser< T >::currentIndex ( ) const
inline

Returns the traverser's current position as an index.

◆ currentValue()

template<typename T >
std::iter_value_t< typename T::const_iterator > Qx::Traverser< T >::currentValue ( ) const
inline

Returns the value at the traverser's current position.

◆ lookAhead()

template<typename T >
std::iter_value_t< typename T::const_iterator > Qx::Traverser< T >::lookAhead ( quint32 count = 1) const
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.

◆ lookBehind()

template<typename T >
std::iter_value_t< typename T::const_iterator > Qx::Traverser< T >::lookBehind ( quint32 count = 1) const
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.

◆ retreat()

template<typename T >
void Qx::Traverser< T >::retreat ( quint32 count = 1)
inline

Reverses the traverser count elements, stopping at the beginning if it is reached.


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