Main Content

matlab::data::TypedIterator<T>

Templated C++ class to provide random access iterator

Description

TypedIterator is the return type of all begin and end functions that support random access.

TypedIterator always iterates in the order elements are in computer memory, which might be column-major or row-major. To determine the memory layout of an array, call getMemoryLayout.

Class Details

Namespace:

matlab::data

Include:

TypedIterator.hpp

Template Parameters

T

Type of element referred to.

Template Instantiations

double

float

int8_t

uint8_t

int16_t

uint16_t

int32_t

uint32_t

int64_t

uint64_t

char16_t

bool

std::complex<double>

std::complex<float>

std::complex<int8_t>

std::complex<uint8_t>

std::complex<int16_t>

std::complex<uint16_t>

std::complex<int32_t>

std::complex<uint32_t>

std::complex<int64_t>

std::complex<uint64_t>

matlab::data::Array
matlab::data::Struct
matlab::data::Enumeration

matlab::data::MATLABString

Constructors

Copy Constructors

TypedIterator(const TypedIterator<T>& rhs)

Description

Creates a shared data copy of a TypedIterator object.

Parameters

const TypedIterator<T>& rhs

Value to copy.

Throws

None

Copy Assignment Operators

TypedIterator<T>& operator=(const TypedIterator<T>& rhs)

Description

Assigns a shared data copy to a TypedIterator object.

Parameters

const TypedIterator<T>& rhs

Value to copy.

Returns

TypedIterator<T>&

Updated instance.

Throws

None

Move Constructors

TypedIterator(TypedIterator<T> &&rhs)

Description

Moves contents of a TypedIterator object to a new instance.

Parameters

TypedIterator<T>&& rhs

Value to move.

Throws

None

Move Assignment Operators

TypedIterator<T>& operator=(TypedIterator<T>&& rhs)

Description

Assigns the input to this TypedIterator object.

Parameters

TypedIterator<T>&& rhs

Value to move.

Returns

TypedIterator<T>&

Updated instance.

Throws

None

Other Operators

operator++

TypedIterator<T>& operator++()

Description

Pre-increment operator, returns the updated iterator. The operator iterates in the order elements are in computer memory, column-major or row-major.

Returns

TypedIterator<T>&

Original iterator.

Throws

None

operator--

TypedIterator<T>& operator--()

Description

Pre-decrement operator, returns the updated iterator.

Returns

TypedIterator<T>&

Original iterator.

Throws

None

operator++(int)

TypedIterator<T> operator++(int)

Description

Post-increment operator, returns the old value of the iterator.

Returns

TypedIterator<T>

Copy of original iterator.

Throws

None

operator--(int)

TypedIterator<T> operator--(int)

Description

Post-decrement operator, returns the old value of the iterator.

Returns

TypedIterator<T>

Copy of original iterator.

Throws

None

operator+=

TypedIterator<T>& operator+=(difference_type d)

Description

Addition assignment operator.

Parameters

difference_type d

Amount to add, specified as std::ptrdiff_t.

Returns

TypedIterator<T>&

Updated instance.

Throws

None

operator-=

TypedIterator<T>& operator-=(difference_type d)

Description

Subtraction assignment operator.

Parameters

difference_type d

Amount to subtract, specified as std::ptrdiff_t.

Returns

TypedIterator<T>&

Updated instance.

Throws

None

operator!=

bool operator!=(const TypedIterator<T>& rhs) const

Parameters

const TypedIterator<T>& rhs

Iterator to compare.

Returns

bool

Returns true if iterators do not point to same element.

Throws

None

operator<

bool operator<(const TypedIterator<T>& rhs) const

Parameters

const TypedIterator<T>& rhs

Iterator to compare.

Returns

bool

Returns true if left-side iterator is less than right-side iterator.

operator>

bool operator>(const TypedIterator<T>& rhs) const

Parameters

const TypedIterator<T>& rhs

Iterator to compare.

Returns

bool

Returns true if left-side iterator is greater than right-side iterator.

operator<=

bool operator<=(const TypedIterator<T>& rhs) const

Parameters

const TypedIterator<T>& rhs

Iterator to compare.

Returns

bool

Returns true if left-side iterator is less than or equal to right-side iterator.

Throws

None

operator>=

bool operator>=(const TypedIterator<T>& rhs) const

Parameters

const TypedIterator<T>& rhs

Iterator to compare.

Returns

bool

Returns true if left-side iterator is greater than or equal to right-side iterator.

Throws

None

operator+

TypedIterator<T> operator+(difference_type d) const

Description

Creates an iterator that is added to this one by the amount passed in.

Parameters

difference_type d

Amount to add, specified as std::ptrdiff_t.

Returns

TypedIterator<T>

Updated instance.

Throws

None

operator-

TypedIterator<T> operator-(difference_type d) const

Description

Creates an iterator that is decremented from this one by the amount passed in.

Parameters

difference_type d

Amount to subtract, specified as std::ptrdiff_t.

Returns

TypedIterator<T>

Updated instance.

Throws

None

operator-

difference_type operator-(const TypedIterator<T>& rhs) const

Parameters

const TypedIterator<T>& rhs

Iterator to compare.

Returns

difference_type

Difference between iterators, specified as std::ptrdiff_t.

Throws

None

operator*

reference operator*() const

Returns

reference

Element pointed to by this iterator, specified as:

  • T& for arithmetic types.

  • Reference<T> for non-arithmetic types.

Throws

None

operator->

pointer operator->()

Returns

pointer

Pointer to element pointed to by this iterator, specified as:

  • T* for arithmetic types.

  • Reference<T>* for non-arithmetic types.

Throws

None

operator[]

reference operator[](const size_t& rhs) const

Description

Get a reference using a linear index.

Returns

reference

Element pointed to by this iterator, specified as:

  • T& for arithmetic types.

  • Reference<T> for non-arithmetic types.

Throws

None

Free Function

operator==

bool operator==(const TypedIterator<T>& rhs) const

Parameters

const TypedIterator<T>& rhs

Iterator to compare.

Returns

bool

Returns true if both iterators point to same element.

Throws

None

Introduced in R2017b