Workspace 6.21.5
Public Types | Public Member Functions | Protected Attributes | List of all members
IndexBasedIterator< ContainerType, IsConst, ValueType, SizeType, DifferenceType, AccessorType > Class Template Reference

Generic base class for adding support for iteration to index-based container classes. More...

#include <Workspace/Application/LanguageUtils/indexbasediterator.h>

Inheritance diagram for IndexBasedIterator< ContainerType, IsConst, ValueType, SizeType, DifferenceType, AccessorType >:
[legend]

Public Types

using const_pointer = value_type const *
 
using const_reference = value_type const &
 
using difference_type = DifferenceType
 
using iterator_category = std::random_access_iterator_tag
 
using pointer = typename std::conditional< IsConst, const ValueType *, ValueType * >::type
 
using reference = typename std::conditional< IsConst, const ValueType &, ValueType & >::type
 
using size_type = SizeType
 
using value_type = ValueType
 

Public Member Functions

 IndexBasedIterator (const IndexBasedIterator< ContainerType, false, ValueType, SizeType, DifferenceType > &it)
 
 IndexBasedIterator (container_type &array, size_type index)
 
 IndexBasedIterator (container_type &array, size_type index, AccessorType accessor)
 
container_type * getContainer () const
 
size_type getIndex () const
 
bool isValid () const
 
bool operator!= (const IndexBasedIterator &it) const
 
reference operator* () const
 
IndexBasedIterator operator+ (int i) const
 
IndexBasedIteratoroperator++ ()
 
IndexBasedIterator operator++ (int)
 
IndexBasedIteratoroperator+= (int i)
 
difference_type operator- (const IndexBasedIterator &it) const
 
IndexBasedIterator operator- (int i) const
 
IndexBasedIteratoroperator-- ()
 
IndexBasedIterator operator-- (int)
 
IndexBasedIteratoroperator-= (int i)
 
pointer operator-> () const
 
bool operator< (const IndexBasedIterator &it) const
 
bool operator<= (const IndexBasedIterator &it) const
 
bool operator== (const IndexBasedIterator &it) const
 
bool operator> (const IndexBasedIterator &it) const
 
bool operator>= (const IndexBasedIterator &it) const
 
reference operator[] (difference_type i) const
 

Protected Attributes

AccessorType accessor_
 
container_type * container_
 
friend ContainerType
 
size_type index_
 

Detailed Description

template<typename ContainerType, bool IsConst = false, typename ValueType = typename ContainerType::value_type, typename SizeType = typename ContainerType::size_type, typename DifferenceType = typename ContainerType::difference_type, typename AccessorType = IndexBasedIteratorPrivate::DefaultAccessor<ContainerType, IsConst, SizeType, ValueType>>
class CSIRO::Application::IndexBasedIterator< ContainerType, IsConst, ValueType, SizeType, DifferenceType, AccessorType >

Generally typedefs of this class will be declared inside the public section of the class definition. For example:

typedef Application::IndexBasedIterator<InputArray, InputScalar, true> const_iterator; typedef Application::IndexBasedIterator<InputArray, InputScalar, false> iterator;

Methods can then be defined to retrieve begin and end iterators:

iterator begin() { return iterator(*this, 0); } const_iterator begin() const { return const_iterator(*this, 0); } iterator end() { return iterator(*this, size()); } const_iterator end() const { return const_iterator(*this, size()); }

Template Parameters
ContainerTypeThe container type to iterate over
IsConstWhether or not the iterator is a const_iterator type
ValueTypeThe type of the values to be returned when dereferencing the iterator. Becomes value_type.
SizeTypeThe size type of the container. Becomes size_type.
DifferenceTypeThe difference type of the container (for when iterators are subtracted). Becomes difference_type.
AccessorTypeCallable access type for retrieving values from the container. Defaults to C::operator[].

Member Typedef Documentation

◆ const_pointer

using const_pointer = value_type const*

◆ const_reference

using const_reference = value_type const&

◆ difference_type

◆ iterator_category

using iterator_category = std::random_access_iterator_tag

◆ pointer

using pointer = typename std::conditional<IsConst, const ValueType*, ValueType*>::type

◆ reference

using reference = typename std::conditional<IsConst, const ValueType&, ValueType&>::type

◆ size_type

using size_type = SizeType

◆ value_type

using value_type = ValueType

Constructor & Destructor Documentation

◆ IndexBasedIterator() [1/3]

IndexBasedIterator ( const IndexBasedIterator< ContainerType, false, ValueType, SizeType, DifferenceType > &  it)
inline

◆ IndexBasedIterator() [2/3]

IndexBasedIterator ( container_type &  array,
size_type  index 
)
inlineexplicit

◆ IndexBasedIterator() [3/3]

IndexBasedIterator ( container_type &  array,
size_type  index,
AccessorType  accessor 
)
inlineexplicit

Member Function Documentation

◆ getContainer()

container_type * getContainer ( ) const
inline

◆ getIndex()

size_type getIndex ( ) const
inline

◆ isValid()

bool isValid ( ) const
inline

◆ operator!=()

bool operator!= ( const IndexBasedIterator< ContainerType, IsConst, ValueType, SizeType, DifferenceType, AccessorType > &  it) const
inline

◆ operator*()

reference operator* ( ) const
inline

◆ operator+()

IndexBasedIterator operator+ ( int  i) const
inline

◆ operator++() [1/2]

IndexBasedIterator & operator++ ( )
inline

◆ operator++() [2/2]

IndexBasedIterator operator++ ( int  )
inline

◆ operator+=()

IndexBasedIterator & operator+= ( int  i)
inline

◆ operator-() [1/2]

difference_type operator- ( const IndexBasedIterator< ContainerType, IsConst, ValueType, SizeType, DifferenceType, AccessorType > &  it) const
inline

◆ operator-() [2/2]

IndexBasedIterator operator- ( int  i) const
inline

◆ operator--() [1/2]

IndexBasedIterator & operator-- ( )
inline

◆ operator--() [2/2]

IndexBasedIterator operator-- ( int  )
inline

◆ operator-=()

IndexBasedIterator & operator-= ( int  i)
inline

◆ operator->()

pointer operator-> ( ) const
inline

◆ operator<()

bool operator< ( const IndexBasedIterator< ContainerType, IsConst, ValueType, SizeType, DifferenceType, AccessorType > &  it) const
inline

◆ operator<=()

bool operator<= ( const IndexBasedIterator< ContainerType, IsConst, ValueType, SizeType, DifferenceType, AccessorType > &  it) const
inline

◆ operator==()

bool operator== ( const IndexBasedIterator< ContainerType, IsConst, ValueType, SizeType, DifferenceType, AccessorType > &  it) const
inline

◆ operator>()

bool operator> ( const IndexBasedIterator< ContainerType, IsConst, ValueType, SizeType, DifferenceType, AccessorType > &  it) const
inline

◆ operator>=()

bool operator>= ( const IndexBasedIterator< ContainerType, IsConst, ValueType, SizeType, DifferenceType, AccessorType > &  it) const
inline

◆ operator[]()

reference operator[] ( difference_type  i) const
inline

Member Data Documentation

◆ accessor_

AccessorType accessor_
protected

◆ container_

container_type* container_
protected

◆ ContainerType

friend ContainerType
protected

◆ index_

size_type index_
protected