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

Detailed Description

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

Read/write 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 Member Functions

 Iterator (T const &container={})
 Create an iterator at the beginning of a container.
 Iterator (Iterator< T > const &)=default
 Iterator (Iterator< T > &&)=default
Iterator< T > & operator= (Iterator< T > const &)=default
Iterator< T > & operator= (Iterator< T > &&)=default
T::value_type & item ()
 Return the current item.
Public Member Functions inherited from msl::ConstIterator< T >
 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.

Additional Inherited Members

Public Types inherited from msl::ConstIterator< T >
using Container = T
 Type of the container iterated on.
Protected Attributes inherited from msl::ConstIterator< T >
Counter _counter
 Current position in the container.
_container
 Container being iterated.

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