C++ Utilities 5.26.1
Useful C++ classes and routines such as argument parser, IO and conversion utilities
Loading...
Searching...
No Matches
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 and must be greater than zero.
 
std::size_t totalSize () const
 Returns the total number of elements.
 
template<std::size_t index>
std::size_t dimensionSize () const
 Returns the number of elements in the specified dimension.
 
T & at (Dimensions... indices)
 Returns the element at the position specified via indices.
 
const T & at (Dimensions... indices) const
 Returns the element at the position specified via indices.
 
T * data ()
 Returns a pointer to the raw data.
 
const T * data () const
 Returns a pointer to the raw data.
 
UnderlyingContainer::template Type< T > & buffer ()
 Allows accessing the underlying buffer directly.
 

Static Public Member Functions

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

Detailed Description

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

The MultiArray class provides an N-dimensional array.

Template Parameters
TSpecifies the type of the data the MultiArray is supposed to contain.
UnderlyingContainerSpecifies the type of the underlying container to use.
DimensionsSpecifies the types used to store the limit/size of the dimensions. Must be safely castable to std::size_t.

Definition at line 76 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 and must be greater than zero.

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 99 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 131 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 139 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 161 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 146 of file multiarray.h.

◆ data() [2/2]

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

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 153 of file multiarray.h.

◆ dimensionCount()

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

Returns the number of dimensions for that type of array.

Definition at line 115 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 ( ) const

Returns the number of elements in the specified dimension.

Definition at line 123 of file multiarray.h.

◆ totalSize()

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

Returns the total number of elements.

Definition at line 108 of file multiarray.h.


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