WARPXM v1.10.0
Loading...
Searching...
No Matches
wxm::multi_iterator< max_dims > Class Template Reference

A multi-dimensional iterator Stores the index in each dimension, as well as a global flattened index. More...

#include <multi_iterator.h>

Detailed Description

template<size_t max_dims>
class wxm::multi_iterator< max_dims >

A multi-dimensional iterator Stores the index in each dimension, as well as a global flattened index.

Template Parameters
max_dimsmaximum number of dimensions this multi-iterator supports

Public Member Functions

template<class... Idcs, class = typename std::enable_if< meta::all<std::is_integral<Idcs>::value...>::value>::type>
 multi_iterator (Idcs... lengths)
 Construct a multi-iterator from a list of lengths.
 
template<class C >
 multi_iterator (const C &cont)
 Construct a multi-iterator from a container which contains the lengths.
 
const std::array< size_t, max_dims > & indices () const
 Gets the multi-dimensional indices.
 
size_t index () const
 Returns the flattened global index.
 
size_t size () const
 Total number of elements.
 
size_t ndims () const
 number of dimensions
 
const std::array< size_t, max_dims > & shape () const
 Gets the multi-dimensional indices.
 
multi_iteratoroperator++ ()
 Increment the multi iterator.
 
multi_iteratoroperator+= (size_t val)
 Increment the multi iterator by val.
 
multi_iteratoradvance (size_t dim)
 Increment the multi iterator in the given dimension.
 
multi_iteratoradvance (size_t dim, size_t val)
 Increment the multi iterator by val in the given dimension.
 

Constructor & Destructor Documentation

◆ multi_iterator() [1/2]

template<size_t max_dims>
template<class... Idcs, class = typename std::enable_if< meta::all<std::is_integral<Idcs>::value...>::value>::type>
wxm::multi_iterator< max_dims >::multi_iterator ( Idcs...  lengths)
inline

Construct a multi-iterator from a list of lengths.

Parameters
lengthsinteger sequence which denotes the shape of this multi-iterator

◆ multi_iterator() [2/2]

template<size_t max_dims>
template<class C >
wxm::multi_iterator< max_dims >::multi_iterator ( const C &  cont)
inline

Construct a multi-iterator from a container which contains the lengths.

Parameters
contsome sort of ordered container which denote the shape of this multi-iterator.

Member Function Documentation

◆ advance() [1/2]

template<size_t max_dims>
multi_iterator & wxm::multi_iterator< max_dims >::advance ( size_t  dim)
inline

Increment the multi iterator in the given dimension.

◆ advance() [2/2]

template<size_t max_dims>
multi_iterator & wxm::multi_iterator< max_dims >::advance ( size_t  dim,
size_t  val 
)
inline

Increment the multi iterator by val in the given dimension.

◆ index()

template<size_t max_dims>
size_t wxm::multi_iterator< max_dims >::index ( ) const
inline

Returns the flattened global index.

◆ indices()

template<size_t max_dims>
const std::array< size_t, max_dims > & wxm::multi_iterator< max_dims >::indices ( ) const
inline

Gets the multi-dimensional indices.

Note that only the first ndims() entries have any meaning

◆ ndims()

template<size_t max_dims>
size_t wxm::multi_iterator< max_dims >::ndims ( ) const
inline

number of dimensions

◆ operator++()

template<size_t max_dims>
multi_iterator & wxm::multi_iterator< max_dims >::operator++ ( )
inline

Increment the multi iterator.

◆ operator+=()

template<size_t max_dims>
multi_iterator & wxm::multi_iterator< max_dims >::operator+= ( size_t  val)
inline

Increment the multi iterator by val.

◆ shape()

template<size_t max_dims>
const std::array< size_t, max_dims > & wxm::multi_iterator< max_dims >::shape ( ) const
inline

Gets the multi-dimensional indices.

Note that only the first ndims() entries have any meaning

◆ size()

template<size_t max_dims>
size_t wxm::multi_iterator< max_dims >::size ( ) const
inline

Total number of elements.


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