 |
LibraryLink Utilities
3.0.1
Modern C++ wrapper over LibraryLink and WSTP
|
Go to the documentation of this file.
9 #ifndef LLU_CONTAINERS_MARRAY_HPP_
10 #define LLU_CONTAINERS_MARRAY_HPP_
12 #include <initializer_list>
14 #include <type_traits>
60 mint
rank() const noexcept {
67 [[nodiscard]]
bool empty() const noexcept {
75 return dims.
get(index);
92 return (*
this)[dims.
getIndex(indices)];
99 const T&
operator[](
const std::vector<mint>& indices)
const {
100 return (*
this)[dims.
getIndex(indices)];
115 const T&
at(mint index)
const;
122 T&
at(
const std::vector<mint>& indices);
129 const T&
at(
const std::vector<mint>& indices)
const;
135 mint getSize() const noexcept
override {
169 for (
auto elem : c) {
T & operator[](const std::vector< mint > &indices)
Get a reference to the data element at given position in a multidimensional container.
Definition: MArray.hpp:91
Abstract class that provides iterators (c/r/begin and c/r/end methods) and subscript operator for any...
Definition: IterableContainer.hpp:20
mint flatCount() const noexcept
Get total number of elements.
Definition: MArrayDimensions.h:126
T & at(mint index)
Get a reference to the data element at given position with bound checking.
Definition: MArray.hpp:141
Main namespace of LibraryLink Utilities.
Definition: Queue.h:13
const std::vector< mint > & get() const noexcept
Get container dimensions in the form of const& to std::vector.
Definition: MArrayDimensions.h:86
Helper class that carries meta-information about container's size and dimensions.
Definition: MArrayDimensions.h:23
const T & at(mint index) const
Get a constant reference to the data element at given position with bound checking.
Definition: MArray.hpp:146
mint getIndex(const std::vector< mint > &indices) const
Convert coordinates of an element in a multidimensional MArray to the corresponding index in a flat l...
Definition: MArrayDimensions.cpp:66
MArray(MArrayDimensions d)
Create new MArray given the dimensions object.
Definition: MArray.hpp:47
This is a class template, where template parameter T is the type of data elements....
Definition: MArray.hpp:36
MArray(const MArray< U > &other)
Converts given MArray of type U into MArray of type T.
Definition: MArray.hpp:55
const MArrayDimensions & dimensions() const
Get a const reference to dimensions object.
Definition: MArray.hpp:81
mint rank() const noexcept
Get container rank.
Definition: MArrayDimensions.h:69
const T & operator[](const std::vector< mint > &indices) const
Get a constant reference to the data element at given position in a multidimensional container.
Definition: MArray.hpp:99
mint getIndexChecked(const std::vector< mint > &indices) const
Check if given coordinates are valid for this container.
Definition: MArrayDimensions.cpp:46
mint dimension(mint index) const
Get dimension value at position index.
Definition: MArray.hpp:74
bool empty() const noexcept
Check whether container is empty.
Definition: MArray.hpp:67
T & at(const std::vector< mint > &indices)
Get a reference to the data element at given position in a multidimensional container.
Definition: MArray.hpp:151
mint rank() const noexcept
Get container rank.
Definition: MArray.hpp:60
const T & at(const std::vector< mint > &indices) const
Get a constant reference to the data element at given position in a multidimensional container.
Definition: MArray.hpp:156
Implementation of the IterableContainer class.
std::ostream & operator<<(std::ostream &os, const MArray< T > &c)
Insertion operator to allow pretty-printing of MArray.
Definition: MArray.hpp:167
Short but generally useful functions.