C++ Utilities  5.4.0
Useful C++ classes and routines such as argument parser, IO and conversion utilities
Public Member Functions | Static Public Member Functions | List of all members
CppUtilities::MultiArray< T, UnderlyingContainer, Dimensions > Class Template Reference

The MultiArray class provides an N-dimensional array. More...

#include <multiarray.h>

Public Member Functions

 MultiArray (Dimensions... dimensionSizes)
 Constructs a new N-dimensional array. The sizes for the dimensions are passed as arguments. More...
 
std::size_t totalSize () const
 Returns the total number of elements. More...
 
template<std::size_t index>
std::size_t dimensionSize () const
 Returns the number of elements in the specified dimension. More...
 
T & at (Dimensions... indices)
 Returns the element at the position specified via indices. More...
 
const T & at (Dimensions... indices) const
 Returns the element at the position specified via indices. More...
 
T * data ()
 Returns a pointer to the raw data. More...
 
const T * data () const
 Returns a pointer to the raw data. More...
 
UnderlyingContainer::template Type< T > & buffer ()
 Allows accessing the underlying buffer directly. More...
 

Static Public Member Functions

static constexpr std::size_t dimensionCount ()
 Returns the number of dimensions for that type of array. More...
 

Detailed Description

template<typename T, typename UnderlyingContainer, typename... Dimensions>
class CppUtilities::MultiArray< T, UnderlyingContainer, Dimensions >

The MultiArray class provides an N-dimensional array.

Definition at line 73 of file multiarray.h.

Constructor & Destructor Documentation

◆ MultiArray()

template<typename T , typename UnderlyingContainer , typename... Dimensions>
CppUtilities::MultiArray< T, UnderlyingContainer, Dimensions >::MultiArray ( Dimensions...  dimensionSizes)

Constructs a new N-dimensional array. The sizes for the dimensions are passed as arguments.

Remarks
The number of dimensions N is deduced from the number of dimensionSizes.
See also
makeMultiArray(), makeFixedSizeMultiArray() and makeNoneOwningMultiArray() for more convenient construction

Definition at line 96 of file multiarray.h.

Member Function Documentation

◆ at() [1/2]

template<typename T , typename UnderlyingContainer , typename... Dimensions>
T & CppUtilities::MultiArray< T, UnderlyingContainer, Dimensions >::at ( Dimensions...  indices)

Returns the element at the position specified via indices.

Remarks
The number of indices must equal dimensionCount().

Definition at line 128 of file multiarray.h.

◆ at() [2/2]

template<typename T , typename UnderlyingContainer , typename... Dimensions>
const T & CppUtilities::MultiArray< T, UnderlyingContainer, Dimensions >::at ( Dimensions...  indices) const

Returns the element at the position specified via indices.

Remarks
The number of indices must equal dimensionCount().

Definition at line 136 of file multiarray.h.

◆ buffer()

template<typename T , typename UnderlyingContainer , typename... Dimensions>
UnderlyingContainer::template Type< T > & CppUtilities::MultiArray< T, UnderlyingContainer, Dimensions >::buffer

Allows accessing the underlying buffer directly.

Remarks
Assign the custom buffer using this method when using NoneOwningMultiArray as UnderlyingContainer.

Definition at line 158 of file multiarray.h.

◆ data() [1/2]

template<typename T , typename UnderlyingContainer , typename... Dimensions>
T * CppUtilities::MultiArray< T, UnderlyingContainer, Dimensions >::data

Returns a pointer to the raw data.

Remarks
Intended for debugging purposes only. The underlying data structure might change in future versions.

Definition at line 143 of file multiarray.h.

◆ data() [2/2]

template<typename T , typename UnderlyingContainer , typename... Dimensions>
const T * CppUtilities::MultiArray< T, UnderlyingContainer, Dimensions >::data

Returns a pointer to the raw data.

Remarks
Intended for debugging purposes only. The underlying data structure might change in future versions.

Definition at line 150 of file multiarray.h.

◆ dimensionCount()

template<typename T , typename UnderlyingContainer , typename... Dimensions>
constexpr std::size_t CppUtilities::MultiArray< T, UnderlyingContainer, Dimensions >::dimensionCount
staticconstexpr

Returns the number of dimensions for that type of array.

Definition at line 112 of file multiarray.h.

◆ dimensionSize()

template<typename T , typename UnderlyingContainer , typename... Dimensions>
template<std::size_t index>
std::size_t CppUtilities::MultiArray< T, UnderlyingContainer, Dimensions >::dimensionSize

Returns the number of elements in the specified dimension.

Definition at line 120 of file multiarray.h.

◆ totalSize()

template<typename T , typename UnderlyingContainer , typename... Dimensions>
std::size_t CppUtilities::MultiArray< T, UnderlyingContainer, Dimensions >::totalSize

Returns the total number of elements.

Definition at line 105 of file multiarray.h.


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