msl 1.3.0
Loading...
Searching...
No Matches
msl::ConstIterator< T > Class Template Reference

Detailed Description

template<typename T>
class msl::ConstIterator< T >

Read-only iterator to a container.

Note
This iterator stores the container it iterates on, as opposed to iterators from the standard C++ library.

#include <Iterator.h>

Public Types

using Container = T
 Type of the container iterated on.

Public Member Functions

 ConstIterator (T const &container={})
 Create an iterator at the beginning of a container.
 ConstIterator (ConstIterator< T > const &)=default
 ConstIterator (ConstIterator< T > &&)=default
ConstIterator< T > & operator= (ConstIterator< T > const &)=default
ConstIterator< T > & operator= (ConstIterator< T > &&)=default
T const & container () const
 Return the container.
void setContainer (T const &container)
 Set the container, reset the counter.
std::size_t index () const
 Return the current index.
T::value_type const & item () const
 Return the current item.
std::size_t end () const
 Return the end value.
ConstIteratorreset ()
 Reset the iterator to the start of the container.
ConstIteratoroperator++ ()
 Move to the next element.
bool first () const
 Test if the index is 0.
bool last () const
 Test if the index is equal to end-1.
bool done () const
 Test if the index is equal to end.

Protected Attributes

Counter _counter
 Current position in the container.
_container
 Container being iterated.

Member Function Documentation

◆ operator++()

template<typename T>
ConstIterator & msl::ConstIterator< T >::operator++ ( )
inline

Move to the next element.

Attention
No bound control is performed.

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