Slice< Tag, iter_type > Class Template Reference
|
CPP API
|
A Slice represents a slice of data along one dimension, given a start and end index into that dimension. More...
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 |
| Slice & | operator= (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, iterator > | slice (Seq< size_t > idx_sequence_) |
| Creates a subslice from the current slice. More... | |
| template<typename OtherTag > | |
| Slice< OtherTag, const_iterator > | slice (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
| using mio::CustomIndexArray< Typ, Tags >::Slice< Tag, iter_type >::const_iterator = Iterator<Type const> |
◆ difference_type
|
private |
◆ iterator
| using mio::CustomIndexArray< Typ, Tags >::Slice< Tag, iter_type >::iterator = Iterator<Type> |
◆ reference
| using mio::CustomIndexArray< Typ, Tags >::Slice< Tag, iter_type >::reference = Type& |
◆ value_type
| using mio::CustomIndexArray< Typ, Tags >::Slice< Tag, iter_type >::value_type = Type |
Constructor & Destructor Documentation
◆ Slice()
|
inline |
Constructs a slice into the CustomIndexarray.
- Parameters
-
dimensions the dimensions of the CustomIndexArray start_iter An iterator to the first element of the data idx_sequence_ A sequence of indices into the slice
Member Function Documentation
◆ as_array()
|
inline |
◆ begin() [1/2]
|
inline |
◆ begin() [2/2]
|
inline |
◆ end() [1/2]
|
inline |
◆ end() [2/2]
|
inline |
◆ numel()
|
inline |
◆ operator=()
|
inline |
Assign same value to each element of the slice.
- Parameters
-
scalar Scalar value.
◆ slice() [1/2]
|
inline |
Creates a subslice from the current slice.
- Template Parameters
-
The Tag corresponding to the dimension of the slice
- Parameters
-
idx_seq An index sequence, consisting of the first index, the number of indices and a stride
- Returns
- The subslice
◆ slice() [2/2]
|
inline |
Creates a subslice from the current slice.
- Template Parameters
-
The Tag corresponding to the dimension of the slice
- Parameters
-
idx_seq An index sequence, consisting of the first index, the number of indices and a stride
- Returns
- The subslice
Friends And Related Function Documentation
◆ operator!=
|
friend |
◆ operator==
|
friend |
Member Data Documentation
◆ data_begin
|
private |
◆ di
|
private |
◆ dl
|
private |
◆ dr
|
private |
◆ idx_sequence
|
private |
◆ m_dimensions
|
private |
Generated by