Main Content

matlab::data::RowMajor

C++ class to create iterators and ranges that iterate in row-major order

Description

Use the RowMajor class to create iterators and ranges that access array elements in row-major order. To determine the memory layout of an array, call getMemoryLayout.

Class Details

Namespace:

matlab::data

Include:

RowMajorIterator.hpp

Iterators

Begin Iterators

template <typename T>
static RowMajorIterator<T> begin(Array& arr)

template <typename T>
static RowMajorIterator<T> begin(TypedArray<T>& arr)

template <typename T>
static RowMajorIterator<T> begin(Reference<Array>& ref)

template <typename T>
static RowMajorIterator<T> begin(TypedArrayRef<T>& ref)

template <typename T>
static RowMajorIterator<T const> begin(const Array& arr)

template <typename T>
static RowMajorIterator<T const> begin(const TypedArray<T>& arr)

template <typename T>
static RowMajorIterator<T const> begin(const Reference<Array>& ref)

template <typename T>
static RowMajorIterator<T const> begin(const TypedArrayRef<T>& ref)

template <typename T>
static RowMajorIterator<T const> cbegin(const TypedArray<T>& arr)

template <typename T>
static RowMajorIterator<T const> cbegin(const Array& arr)

template <typename T>
static RowMajorIterator<T const> cbegin(const Reference<Array>& ref)

template <typename T>
static RowMajorIterator<T const> cbegin(const TypedArrayRef<T>& ref)
Description

Create a RowMajorIterator to the beginning of the input array. For best performance when reading data from an array, use functions that return RowMajorIterator<T const>.

Parameters

Array& arr

Array used to create the iterator, specified as const or non-const.

TypedArray<T>& arr

Array used to create the iterator, specified as const or non-const.

Reference<Array>& ref

Reference to the array used to create the iterator, specified as const or non-const.

TypedArrayRef<T>& ref

Reference to the array used to create the iterator, specified as const or non-const.

Returns

RowMajorIterator<T>

Non-const iterator to the beginning of the array.

RowMajorIterator<T const>

Const iterator to the beginning of the array.

Throws

matlab::data::TypeMismatchException

Element of Array does not match <T>.

End Iterators

template <typename T>
static RowMajorIterator<T> end(Array& arr)

template <typename T>
static RowMajorIterator<T> end(TypedArray<T>& arr)

template <typename T>
static RowMajorIterator<T> end(Reference<Array>& ref)

template <typename T>
static RowMajorIterator<T> end(TypedArrayRef<T>& ref)

template <typename T>
static RowMajorIterator<T const> end(const Array& arr)

template <typename T>
static RowMajorIterator<T const> end(const TypedArray<T>& arr)

template <typename T>
static RowMajorIterator<T const> end(const Reference<Array>& ref)

template <typename T>
static RowMajorIterator<T const> end(const TypedArrayRef<T>& ref)

template <typename T>
static RowMajorIterator<T const> cend(const TypedArray<T>& arr)

template <typename T>
static RowMajorIterator<T const> cend(const Array& arr)

template <typename T>
static RowMajorIterator<T const> cend(const Reference<Array>& ref)

template <typename T>
static RowMajorIterator<T const> cend(const TypedArrayRef<T>& ref)
Description

Create a RowMajorIterator to the end of the input array.

Parameters

Array& arr

Array used to create the iterator, specified as const or non-const.

TypedArray<T>& arr

Array used to create the iterator.

Reference<Array>& ref

Reference to the array used to create the iterator, specified as const or non-const.

TypedArrayRef<T>& ref

Reference to the array used to create the iterator, specified as const or non-const.

Returns

RowMajorIterator<T>

Non-const iterator to the end of the array.

RowMajorIterator<T const>

Const iterator to the end of the array.

Throws

matlab::data::TypeMismatchException

Element of Array does not match <T>.

Member Functions

readOnlyElements

template <typename T>
static Range<RowMajorIterator<T const>> readOnlyElements(const Array& arr)

template <typename T>
static Range<RowMajorIterator<T const>> readOnlyElements(const TypedArray<T>& arr)

template <typename T>
static Range<RowMajorIterator<T const>> readOnlyElements(const Reference<Array>& ref)

template <typename T>
static Range<RowMajorIterator<T const>> readOnlyElements(const TypedArrayRef<T>& ref)
Description

Create a Range containing const iterators. Use for best performance when reading data from an array.

Parameters

const Array& arr

Input array used to create the iterators.

const TypedArray<T>& arr

Input array used to create the iterators.

const Reference<Array>& ref

Reference to the input array used to create the iterators.

const TypedArrayRef<T>& ref

Reference to the input array used to create the iterators.

Returns

Range<RowMajorIterator<T const>>

Range containing const RowMajorIterators that point to the beginning and the end of the input array.

Throws

matlab::data::TypeMismatchException

Element of Array does not match <T>.

writableElements

template <typename T>
static Range<RowMajorIterator<T>> writableElements(Array& arr)

template <typename T>
static Range<RowMajorIterator<T>> writableElements(TypedArray<T>& arr)

template <typename T>
static Range<RowMajorIterator<T>> writableElements(Reference<Array>& ref)

template <typename T>
static Range<RowMajorIterator<T>> writableElements(TypedArrayRef<T>& ref)
Description

Create a Range containing non-const iterators. For best performance when reading data from an array, use readOnlyElements, which returns RowMajorIterator<T const>.

Parameters

Array& arr

Array used to create the iterators.

TypedArray<T>& arr

Array used to create the iterators.

Reference<Array>& ref

Reference to array used to create the iterators.

TypedArrayRef<T>& ref

Reference to array used to create the iterators.

Returns

Range<RowMajorIterator<T>>

Range containing non-const RowMajorIterators that point to the beginning and the end of the input array.

Throws

matlab::data::TypeMismatchException

Element of Array does not match <T>.

Version History

Introduced in R2022a