Slice< Tag, iter_type > Class Template Reference

CPP API: mio::CustomIndexArray< Typ, Tags >::Slice< Tag, iter_type > Class Template Reference
mio::CustomIndexArray< Typ, Tags >::Slice< Tag, iter_type > Class Template Reference

A Slice represents a slice of data along one dimension, given a start and end index into that dimension. More...

Collaboration diagram for mio::CustomIndexArray< Typ, Tags >::Slice< Tag, iter_type >:

Classes

class  Iterator
 

Public Types

using const_iterator = Iterator< Type const >
 
using iterator = Iterator< Type >
 
using reference = Type &
 
using value_type = Type
 

Public Member Functions

CustomIndexArray< Type, Tags... > as_array ()
 
iterator begin ()
 
const_iterator begin () const
 
iterator end ()
 
const_iterator end () const
 
size_t numel () const
 
Sliceoperator= (const Type &scalar)
 Assign same value to each element of the slice. More...
 
 Slice (Index const &dimensions, iter_type const &start_iter, Seq< size_t > idx_sequence_)
 Constructs a slice into the CustomIndexarray. More...
 
template<typename OtherTag >
Slice< OtherTag, iteratorslice (Seq< size_t > idx_sequence_)
 Creates a subslice from the current slice. More...
 
template<typename OtherTag >
Slice< OtherTag, const_iteratorslice (Seq< size_t > idx_sequence_) const
 Creates a subslice from the current slice. More...
 

Private Types

using difference_type = typename iter_type::difference_type
 

Private Attributes

iter_type data_begin
 
size_t di
 
size_t dl
 
size_t dr
 
Seq< size_t > idx_sequence
 
Index m_dimensions
 

Friends

bool operator!= (const Slice &a, const Slice &b)
 
bool operator== (const Slice &a, const Slice &b)
 

Detailed Description

template<class Typ, class... Tags>
template<typename Tag, typename iter_type>
class mio::CustomIndexArray< Typ, Tags >::Slice< Tag, iter_type >

A Slice represents a slice of data along one dimension, given a start and end index into that dimension.

Its sole use is to provide an iterator for the data along this slice.

If dims = (d0,d1,...d_i,...,dN) are the dimension sizes of this array, and d_i is the dimension size of the current slice, the indices into the data array are given by

i*d_i + j*d_i*d_right + k

where

  0 <= i <  d_right

start <= j <= end 0 <= k < d_left

and start and end are the start and end indices for this slice, d_left = d_0*d_1*...*d_(i-1) and d_right = d_(i+1)*...*d_N. If d_i = d_0, d_left=1 and if d_i = d_N, d_right=1.

A slice iterator will store the indices (i,j,k) and increment k before j before i, so that the returned values are traversed in the flat index from front to back.

Member Typedef Documentation

◆ const_iterator

template<class Typ , class... Tags>
template<typename Tag , typename iter_type >
using mio::CustomIndexArray< Typ, Tags >::Slice< Tag, iter_type >::const_iterator = Iterator<Type const>

◆ difference_type

template<class Typ , class... Tags>
template<typename Tag , typename iter_type >
using mio::CustomIndexArray< Typ, Tags >::Slice< Tag, iter_type >::difference_type = typename iter_type::difference_type
private

◆ iterator

template<class Typ , class... Tags>
template<typename Tag , typename iter_type >
using mio::CustomIndexArray< Typ, Tags >::Slice< Tag, iter_type >::iterator = Iterator<Type>

◆ reference

template<class Typ , class... Tags>
template<typename Tag , typename iter_type >
using mio::CustomIndexArray< Typ, Tags >::Slice< Tag, iter_type >::reference = Type&

◆ value_type

template<class Typ , class... Tags>
template<typename Tag , typename iter_type >
using mio::CustomIndexArray< Typ, Tags >::Slice< Tag, iter_type >::value_type = Type

Constructor & Destructor Documentation

◆ Slice()

template<class Typ , class... Tags>
template<typename Tag , typename iter_type >
mio::CustomIndexArray< Typ, Tags >::Slice< Tag, iter_type >::Slice ( Index const &  dimensions,
iter_type const &  start_iter,
Seq< size_t >  idx_sequence_ 
)
inline

Constructs a slice into the CustomIndexarray.

Parameters
dimensionsthe dimensions of the CustomIndexArray
start_iterAn iterator to the first element of the data
idx_sequence_A sequence of indices into the slice

Member Function Documentation

◆ as_array()

template<class Typ , class... Tags>
template<typename Tag , typename iter_type >
CustomIndexArray<Type, Tags...> mio::CustomIndexArray< Typ, Tags >::Slice< Tag, iter_type >::as_array ( )
inline

◆ begin() [1/2]

template<class Typ , class... Tags>
template<typename Tag , typename iter_type >
iterator mio::CustomIndexArray< Typ, Tags >::Slice< Tag, iter_type >::begin ( )
inline

◆ begin() [2/2]

template<class Typ , class... Tags>
template<typename Tag , typename iter_type >
const_iterator mio::CustomIndexArray< Typ, Tags >::Slice< Tag, iter_type >::begin ( ) const
inline

◆ end() [1/2]

template<class Typ , class... Tags>
template<typename Tag , typename iter_type >
iterator mio::CustomIndexArray< Typ, Tags >::Slice< Tag, iter_type >::end ( )
inline

◆ end() [2/2]

template<class Typ , class... Tags>
template<typename Tag , typename iter_type >
const_iterator mio::CustomIndexArray< Typ, Tags >::Slice< Tag, iter_type >::end ( ) const
inline

◆ numel()

template<class Typ , class... Tags>
template<typename Tag , typename iter_type >
size_t mio::CustomIndexArray< Typ, Tags >::Slice< Tag, iter_type >::numel ( ) const
inline

◆ operator=()

template<class Typ , class... Tags>
template<typename Tag , typename iter_type >
Slice& mio::CustomIndexArray< Typ, Tags >::Slice< Tag, iter_type >::operator= ( const Type scalar)
inline

Assign same value to each element of the slice.

Parameters
scalarScalar value.

◆ slice() [1/2]

template<class Typ , class... Tags>
template<typename Tag , typename iter_type >
template<typename OtherTag >
Slice<OtherTag, iterator> mio::CustomIndexArray< Typ, Tags >::Slice< Tag, iter_type >::slice ( Seq< size_t >  idx_sequence_)
inline

Creates a subslice from the current slice.

Template Parameters
TheTag corresponding to the dimension of the slice
Parameters
idx_seqAn index sequence, consisting of the first index, the number of indices and a stride
Returns
The subslice

◆ slice() [2/2]

template<class Typ , class... Tags>
template<typename Tag , typename iter_type >
template<typename OtherTag >
Slice<OtherTag, const_iterator> mio::CustomIndexArray< Typ, Tags >::Slice< Tag, iter_type >::slice ( Seq< size_t >  idx_sequence_) const
inline

Creates a subslice from the current slice.

Template Parameters
TheTag corresponding to the dimension of the slice
Parameters
idx_seqAn index sequence, consisting of the first index, the number of indices and a stride
Returns
The subslice

Friends And Related Function Documentation

◆ operator!=

template<class Typ , class... Tags>
template<typename Tag , typename iter_type >
bool operator!= ( const Slice< Tag, iter_type > &  a,
const Slice< Tag, iter_type > &  b 
)
friend

◆ operator==

template<class Typ , class... Tags>
template<typename Tag , typename iter_type >
bool operator== ( const Slice< Tag, iter_type > &  a,
const Slice< Tag, iter_type > &  b 
)
friend

Member Data Documentation

◆ data_begin

template<class Typ , class... Tags>
template<typename Tag , typename iter_type >
iter_type mio::CustomIndexArray< Typ, Tags >::Slice< Tag, iter_type >::data_begin
private

◆ di

template<class Typ , class... Tags>
template<typename Tag , typename iter_type >
size_t mio::CustomIndexArray< Typ, Tags >::Slice< Tag, iter_type >::di
private

◆ dl

template<class Typ , class... Tags>
template<typename Tag , typename iter_type >
size_t mio::CustomIndexArray< Typ, Tags >::Slice< Tag, iter_type >::dl
private

◆ dr

template<class Typ , class... Tags>
template<typename Tag , typename iter_type >
size_t mio::CustomIndexArray< Typ, Tags >::Slice< Tag, iter_type >::dr
private

◆ idx_sequence

template<class Typ , class... Tags>
template<typename Tag , typename iter_type >
Seq<size_t> mio::CustomIndexArray< Typ, Tags >::Slice< Tag, iter_type >::idx_sequence
private

◆ m_dimensions

template<class Typ , class... Tags>
template<typename Tag , typename iter_type >
Index mio::CustomIndexArray< Typ, Tags >::Slice< Tag, iter_type >::m_dimensions
private