MultiIndexIterator< MultiIndex > Class Template Reference

CPP API: mio::MultiIndexIterator< MultiIndex > Class Template Reference
mio::MultiIndexIterator< MultiIndex > Class Template Reference

A Range that can be used to iterate over a MultiIndex. More...

#include <index_range.h>

Public Types

using difference_type = std::ptrdiff_t
 
using iterator_category = std::forward_iterator_tag
 
using pointer = void
 
using reference = value_type
 
using value_type = MultiIndex
 

Public Member Functions

 MultiIndexIterator ()
 Default constructed MultiIndexIterator. More...
 
 MultiIndexIterator (value_type index, reference dimensions)
 Iterator for MultiIndices. More...
 
bool operator!= (const MultiIndexIterator &other) const
 Inequality operator. More...
 
reference operator* () const
 Dereference operator. More...
 
MultiIndexIteratoroperator++ ()
 Pre-increment operator. More...
 
MultiIndexIterator operator++ (int)
 Post-increment operator. More...
 
bool operator== (const MultiIndexIterator &other) const
 Equality operator. More...
 

Private Member Functions

template<size_t I = MultiIndex::size - 1>
void increment_index ()
 Implementation of ++. More...
 

Private Attributes

value_type m_dims
 Copy of range dimensions. More...
 
value_type m_index
 Index used for iteration. More...
 

Detailed Description

template<class MultiIndex>
class mio::MultiIndexIterator< MultiIndex >

A Range that can be used to iterate over a MultiIndex.

Template Parameters
MultiIndexA type mio::Index<Categories...> for some set of categories.

Member Typedef Documentation

◆ difference_type

template<class MultiIndex >
using mio::MultiIndexIterator< MultiIndex >::difference_type = std::ptrdiff_t

◆ iterator_category

template<class MultiIndex >
using mio::MultiIndexIterator< MultiIndex >::iterator_category = std::forward_iterator_tag

◆ pointer

template<class MultiIndex >
using mio::MultiIndexIterator< MultiIndex >::pointer = void

◆ reference

template<class MultiIndex >
using mio::MultiIndexIterator< MultiIndex >::reference = value_type

◆ value_type

template<class MultiIndex >
using mio::MultiIndexIterator< MultiIndex >::value_type = MultiIndex

Constructor & Destructor Documentation

◆ MultiIndexIterator() [1/2]

template<class MultiIndex >
mio::MultiIndexIterator< MultiIndex >::MultiIndexIterator ( )
inline

Default constructed MultiIndexIterator.

This will not construct a valid iterator.

◆ MultiIndexIterator() [2/2]

template<class MultiIndex >
mio::MultiIndexIterator< MultiIndex >::MultiIndexIterator ( value_type  index,
reference  dimensions 
)
inline

Iterator for MultiIndices.

Parameters
indexInitial value for the iterator position.
dimensionsA reference to the dimensions of the MultiIndex.

Member Function Documentation

◆ increment_index()

template<class MultiIndex >
template<size_t I = MultiIndex::size - 1>
void mio::MultiIndexIterator< MultiIndex >::increment_index ( )
inlineprivate

Implementation of ++.

Increments m_index.

Template Parameters
Iposition in the MultiIndex.

◆ operator!=()

template<class MultiIndex >
bool mio::MultiIndexIterator< MultiIndex >::operator!= ( const MultiIndexIterator< MultiIndex > &  other) const
inline

Inequality operator.

◆ operator*()

template<class MultiIndex >
reference mio::MultiIndexIterator< MultiIndex >::operator* ( ) const
inline

Dereference operator.

◆ operator++() [1/2]

template<class MultiIndex >
MultiIndexIterator& mio::MultiIndexIterator< MultiIndex >::operator++ ( )
inline

Pre-increment operator.

◆ operator++() [2/2]

template<class MultiIndex >
MultiIndexIterator mio::MultiIndexIterator< MultiIndex >::operator++ ( int  )
inline

Post-increment operator.

◆ operator==()

template<class MultiIndex >
bool mio::MultiIndexIterator< MultiIndex >::operator== ( const MultiIndexIterator< MultiIndex > &  other) const
inline

Equality operator.

Member Data Documentation

◆ m_dims

template<class MultiIndex >
value_type mio::MultiIndexIterator< MultiIndex >::m_dims
private

Copy of range dimensions.

◆ m_index

template<class MultiIndex >
value_type mio::MultiIndexIterator< MultiIndex >::m_index
private

Index used for iteration.