matlab::data::Array
C++ base class for all array types
Description
Use Array
objects to represent single and multi-dimensional arrays. The
Array
class provides methods to get generic information about all
arrays, such as dimensions and type. The class has methods to create both deep (cloned)
copies and shared data copies and supports copy-on-write semantics.
To construct Array
objects, use ArrayFactory
methods.
Class Details
Namespace: | matlab::data |
Include: | MDArray.hpp |
Constructors
Default Constructor
Array()
None
Copy Constructors
Array(const Array& rhs)
Creates a shared data copy of an Array
object.
|
Value to copy. |
None
Copy Assignment Operators
Array& operator=(const Array& rhs)
Assigns a shared data copy to an Array
object.
|
Value to copy. |
|
Updated instance. |
None
Move Constructors
Array(Array&& rhs)
Moves contents of an Array
object to a new instance.
|
Value to move. |
None
Move Assignment Operators
Array& operator=(Array&& rhs)
Assigns the input to this Array
object.
|
Value to move. |
|
Updated instance. |
None
Destructor
virtual ~Array()
Indexing Operators
operator[]
ArrayElementRef<false> operator[](size_t idx)
ArrayElementRef<true> operator[](size_t idx)
const
Enables []
indexing on const
and
non-const
arrays. Indexing is 0-based.
|
First array index |
|
Temporary object containing the index specified. The return value allows the element of the array to be modified or retrieved. |
|
Temporary object containing the index specified. The return value allows the element of the array to be retrieved, but not modified. |
None
Member Functions
getType
ArrayType getType() const
|
Array type. |
None
getMemoryLayout
MemoryLayout getMemoryLayout() const
| Memory layout for array, specified as
|
| Arrays created before R2019a did not support different memory layouts. The memory layout was always column-major. |
getDimensions
ArrayDimensions getDimensions() const
|
Vector of each dimension in array. |
None
getNumberOfElements
size_t getNumberOfElements() const
|
The number of elements in array. |
None
isEmpty
bool isEmpty() const
|
True if array is empty. False if array is not empty. |
None
Free Functions
getReadOnlyElements
template <typename T> Range<TypedIterator, T const> getReadOnlyElements(const Array& arr)
Get a range containing the elements of the Array
. Iterators
contained in the range are const
.
|
|
|
Range containing |
|
|
getWritableElements
template <typename T> Range<TypedIterator, T> getWritableElements(Array& arr)
Get a range containing the elements of the Array
. Iterators
contained in the range are non-const
.
|
|
|
Range containing |
|
|