Iterators module
#include "diplib.h"
template<typename T>
dip::SampleIterator class

An iterator to iterate over samples in a tensor, or pixels on an image line.

This is the simplest iterator available in this library, and is most like working with a pointer to a data segment. The only difference with a pointer is that the data stride is taken into account.

Satisfies all the requirements for a mutable RandomAccessIterator.

This means that you can increment and decrement the iterator, add or subtract an integer from it, dereference it, index it using the [] operator, as well as compare two iterators or take the difference between them (as long as they reference samples within the same data segment). It is default constructible and swappable, but the default constructed iterator is invalid and should not be dereferenced.

Note that when an image is stripped or reforged, all its iterators are invalidated.

Constructors, destructors, assignment and conversion operators

SampleIterator() noexcept
Default constructor yields an invalid iterator that cannot be dereferenced
SampleIterator(dip::SampleIterator::pointer ptr, dip::sint stride = 1) noexcept
To construct a useful iterator, provide a pointer and a stride

Aliases

using difference_type = dip::sint
The type of difference between iterators
using iterator_category = std::random_access_iterator_tag
Iterator category
using pointer = T*
The type of a pointer to a sample
using reference = T&
The type of a reference to a sample
using value_type = T
The data type of the sample, obtained when dereferencing the iterator

Functions

auto Pointer() const -> dip::SampleIterator::pointer
Returns the pointer
auto Stride() const -> dip::sint
Returns the stride
void swap(dip::SampleIterator& other) noexcept
Swap

Operators

auto operator bool() const -> bool explicit
Test returns false if the iterator cannot be dereferenced (is a null pointer)
auto operator SampleIterator() const -> dip::SampleIterator
Convert from non-const iterator to const iterator
auto operator!=(dip::SampleIterator const& other) const -> bool
Inequality comparison
auto operator*() const -> dip::SampleIterator::reference
Dereference
auto operator++() -> dip::SampleIterator&
Pre-increment
auto operator++(int ) -> dip::SampleIterator
Post-increment
template<typename I, typename <SFINAE>>
auto operator+=(I index) -> dip::SampleIterator&
Add integer
auto operator-(dip::SampleIterator const& it) const -> dip::SampleIterator::difference_type
Difference between iterators
auto operator--() -> dip::SampleIterator&
Pre-decrement
auto operator--(int ) -> dip::SampleIterator
Post-decrement
template<typename I, typename <SFINAE>>
auto operator-=(I index) -> dip::SampleIterator&
Subtract integer
auto operator->() const -> dip::SampleIterator::pointer
Dereference
auto operator<(dip::SampleIterator const& other) const -> bool
Smaller than comparison
auto operator<=(dip::SampleIterator const& other) const -> bool
Not larger than comparison
auto operator==(dip::SampleIterator const& other) const -> bool
Equality comparison
auto operator>(dip::SampleIterator const& other) const -> bool
Larger than comparison
auto operator>=(dip::SampleIterator const& other) const -> bool
Not smaller than comparison
template<typename I, typename <SFINAE>>
auto operator[](I index) const -> dip::SampleIterator::reference
Index

Alias documentation

template<typename T>
using iterator_category = std::random_access_iterator_tag

Iterator category

template<typename T>
using value_type = T

The data type of the sample, obtained when dereferencing the iterator

template<typename T>
using difference_type = dip::sint

The type of difference between iterators

template<typename T>
using reference = T&

The type of a reference to a sample

template<typename T>
using pointer = T*

The type of a pointer to a sample

template<typename T>
template<typename T>
using dip::ConstSampleIterator = dip::SampleIterator

A const iterator to iterate over samples in a tensor, or pixels on an image line.

This iterator is identical to dip::SampleIterator, but with a const value type.

Satisfies all the requirements for a non-mutable RandomAccessIterator.

Function documentation

template<typename T>
SampleIterator( ) noexcept

Default constructor yields an invalid iterator that cannot be dereferenced

template<typename T>
SampleIterator( dip::SampleIterator::pointer ptr, dip::sint stride = 1) noexcept

To construct a useful iterator, provide a pointer and a stride

template<typename T>
void swap( dip::SampleIterator& other) noexcept

Swap

template<typename T>
dip::sint Stride( ) const

Returns the stride

template<typename T>
dip::SampleIterator::pointer Pointer( ) const

Returns the pointer

template<typename T>
dip::SampleIterator operator SampleIterator( ) const

Convert from non-const iterator to const iterator

template<typename T>
dip::SampleIterator::reference operator*( ) const

Dereference

template<typename T>
dip::SampleIterator::pointer operator->( ) const

Dereference

template<typename T>
template<typename I, typename <SFINAE>>
dip::SampleIterator::reference operator[]( I index) const

Index

template<typename T>
dip::SampleIterator& operator++( )

Pre-increment

template<typename T>
dip::SampleIterator& operator--( )

Pre-decrement

template<typename T>
dip::SampleIterator operator++( int )

Post-increment

template<typename T>
dip::SampleIterator operator--( int )

Post-decrement

template<typename T>
template<typename I, typename <SFINAE>>
dip::SampleIterator& operator+=( I index)

Add integer

template<typename T>
template<typename I, typename <SFINAE>>
dip::SampleIterator& operator-=( I index)

Subtract integer

template<typename T>
dip::SampleIterator::difference_type operator-( dip::SampleIterator const& it) const

Difference between iterators

template<typename T>
bool operator bool( ) const explicit

Test returns false if the iterator cannot be dereferenced (is a null pointer)

template<typename T>
bool operator==( dip::SampleIterator const& other) const

Equality comparison

template<typename T>
bool operator!=( dip::SampleIterator const& other) const

Inequality comparison

template<typename T>
bool operator>( dip::SampleIterator const& other) const

Larger than comparison

template<typename T>
bool operator<( dip::SampleIterator const& other) const

Smaller than comparison

template<typename T>
bool operator>=( dip::SampleIterator const& other) const

Not smaller than comparison

template<typename T>
bool operator<=( dip::SampleIterator const& other) const

Not larger than comparison

template<typename T>
template<typename T, typename I, typename <SFINAE>>
dip::SampleIterator dip::operator+( dip::SampleIterator it, I n)

Add integer to a sample iterator

template<typename T>
template<typename T, typename I, typename <SFINAE>>
dip::SampleIterator dip::operator-( dip::SampleIterator it, I n)

Subtract integer from a sample iterator