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 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

Functions

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

Operators

auto operator SampleIterator() const -> dip::SampleIterator
Convert from non-const iterator to const iterator
auto operator*() const -> dip::SampleIterator::reference
Dereference
auto operator->() const -> dip::SampleIterator::pointer
Dereference
template<typename I, typename <SFINAE>>
auto operator[](I index) const -> dip::SampleIterator::reference
Index
auto operator++() -> dip::SampleIterator&
Pre-increment
auto operator--() -> dip::SampleIterator&
Pre-decrement
auto operator++(int ) -> dip::SampleIterator
Post-increment
auto operator--(int ) -> dip::SampleIterator
Post-decrement
template<typename I, typename <SFINAE>>
auto operator+=(I index) -> dip::SampleIterator&
Add integer
template<typename I, typename <SFINAE>>
auto operator-=(I index) -> dip::SampleIterator&
Subtract integer
auto operator-(dip::SampleIterator 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==(dip::SampleIterator const& other) const -> bool
Equality comparison
auto operator!=(dip::SampleIterator const& other) const -> bool
Inequality comparison
auto operator>(dip::SampleIterator const& other) const -> bool
Larger than comparison
auto operator<(dip::SampleIterator const& other) const -> bool
Smaller than comparison
auto operator>=(dip::SampleIterator const& other) const -> bool
Not smaller than comparison
auto operator<=(dip::SampleIterator const& other) const -> bool
Not larger than comparison

Alias documentation

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.