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


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


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


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

Alias documentation

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

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.