SeqAn3 3.4.0-rc.4
The Modern C++ library for sequence analysis.
|
The forward declared iterator type for pairwise_combine_view. More...
#include <seqan3/utility/views/pairwise_combine.hpp>
Public Types | |
Associated types | |
using | difference_type = std::ptrdiff_t |
The difference type. | |
using | value_type = std::tuple< underlying_val_t, underlying_val_t > |
The value type. | |
using | reference = common_tuple< underlying_ref_t, underlying_ref_t > |
The reference type. | |
using | pointer = void |
The pointer type. | |
using | iterator_concept = detail::iterator_concept_tag_t< underlying_iterator_type > |
The iterator concept tag. | |
![]() | |
using | iterator_category = MAYBE_PRESENT(std::iterator_traits< std::ranges::iterator_t< range_type > >::iterator_category) |
The iterator category tag. (not always present!) | |
Public Member Functions | |
Constructors, destructor and assignment | |
basic_iterator ()=default | |
Defaulted. | |
basic_iterator (basic_iterator const &)=default | |
Defaulted. | |
basic_iterator (basic_iterator &&)=default | |
Defaulted. | |
basic_iterator & | operator= (basic_iterator const &)=default |
Defaulted. | |
basic_iterator & | operator= (basic_iterator &&)=default |
Defaulted. | |
~basic_iterator ()=default | |
Defaulted. | |
constexpr | basic_iterator (underlying_iterator_type iter, underlying_iterator_type begin_it, underlying_iterator_type end_it) noexcept |
Constructs the iterator from the current underlying iterator and the end iterator of the underlying range. | |
template<typename other_range_type > requires std::convertible_to<other_range_type, range_type &> && std::same_as<std::remove_const_t<other_range_type>, std::remove_const_t<range_type>> | |
constexpr | basic_iterator (basic_iterator< other_range_type > other) noexcept |
Constructs const iterator from non-const iterator. | |
Accessors | |
constexpr reference | operator* () const noexcept(noexcept(*std::declval< underlying_iterator_type >())) |
Accesses the pointed-to element. | |
constexpr reference | operator[] (size_t const index) const noexcept(noexcept(std::declval< basic_iterator & >().from_index(1))) |
Access the element at the given index. | |
Comparison operators | |
These operators are available if the | |
template<typename other_range_type > requires std::equality_comparable_with<underlying_iterator_type, std::ranges::iterator_t<other_range_type>> && std::same_as<std::remove_const_t<range_type>, std::remove_const_t<other_range_type>> | |
constexpr bool | operator== (basic_iterator< other_range_type > const &rhs) const noexcept(noexcept(std::declval< underlying_iterator_type & >()==std::declval< underlying_iterator_type & >())) |
Checks whether *this is equal to rhs . | |
template<typename other_range_type > requires std::equality_comparable_with<underlying_iterator_type, std::ranges::iterator_t<other_range_type>> && std::same_as<std::remove_const_t<range_type>, std::remove_const_t<other_range_type>> | |
constexpr bool | operator!= (basic_iterator< other_range_type > const &rhs) const noexcept(noexcept(std::declval< underlying_iterator_type & >() !=std::declval< underlying_iterator_type & >())) |
Checks whether *this is not equal to rhs . | |
template<typename other_range_type > requires std::totally_ordered_with<underlying_iterator_type, std::ranges::iterator_t<other_range_type>> && std::same_as<std::remove_const_t<range_type>, std::remove_const_t<other_range_type>> | |
constexpr bool | operator< (basic_iterator< other_range_type > const &rhs) const noexcept(noexcept(std::declval< underlying_iterator_type & >()< std::declval< underlying_iterator_type & >())) |
Checks whether *this is less than rhs . | |
template<typename other_range_type > requires std::totally_ordered_with<underlying_iterator_type, std::ranges::iterator_t<other_range_type>> && std::same_as<std::remove_const_t<range_type>, std::remove_const_t<other_range_type>> | |
constexpr bool | operator> (basic_iterator< other_range_type > const &rhs) const noexcept(noexcept(std::declval< underlying_iterator_type & >() > std::declval< underlying_iterator_type & >())) |
Checks whether *this is greater than rhs . | |
template<typename other_range_type > requires std::totally_ordered_with<underlying_iterator_type, std::ranges::iterator_t<other_range_type>> && std::same_as<std::remove_const_t<range_type>, std::remove_const_t<other_range_type>> | |
constexpr bool | operator<= (basic_iterator< other_range_type > const &rhs) const noexcept(noexcept(std::declval< underlying_iterator_type & >()<=std::declval< underlying_iterator_type & >())) |
Checks whether *this is less than or equal to rhs . | |
template<typename other_range_type > requires std::totally_ordered_with<underlying_iterator_type, std::ranges::iterator_t<other_range_type>> && std::same_as<std::remove_const_t<range_type>, std::remove_const_t<other_range_type>> | |
constexpr bool | operator>= (basic_iterator< other_range_type > const &rhs) const noexcept(noexcept(std::declval< underlying_iterator_type & >() >=std::declval< underlying_iterator_type & >())) |
Checks whether *this is greater than or equal to rhs . | |
Private Types | |
using | underlying_iterator_type = std::ranges::iterator_t< range_type > |
Alias type for the iterator over the passed range type. | |
using | underlying_ref_t = std::iter_reference_t< underlying_iterator_type > |
Alias for the reference type of the underlying iterator type. | |
using | underlying_val_t = std::iter_value_t< underlying_iterator_type > |
Alias for the value type of the underlying iterator type. | |
Private Member Functions | |
constexpr void | from_index (size_t const index) noexcept(noexcept(std::declval< underlying_iterator_type & >() - std::declval< underlying_iterator_type & >()) &&noexcept(std::declval< underlying_iterator_type & >()+1)) |
Sets the iterator to the given index. | |
constexpr size_t | to_index () const noexcept(noexcept(std::declval< underlying_iterator_type & >() - std::declval< underlying_iterator_type & >())) |
Returns the index for the current iterator position. | |
Private Attributes | |
underlying_iterator_type | begin_it {} |
The begin of the underlying range. | |
underlying_iterator_type | end_it {} |
The end of the underlying range. | |
underlying_iterator_type | first_it {} |
The iterator pointing to the first element of the pairwise combination. | |
underlying_iterator_type | second_it {} |
The iterator pointing to the second element of the pairwise combination. | |
Friends | |
template<typename other_range_type > | |
class | basic_iterator |
Friend declaration for iterator with different range const-ness. | |
Arithmetic operators | |
constexpr friend basic_iterator | operator+ (difference_type const offset, basic_iterator iter) noexcept(noexcept(std::declval< basic_iterator< range_type > & >().from_index(1))) |
Advances the iterator by the given offset; underlying_iterator_type must model \ std::random_access_iterator. | |
constexpr basic_iterator & | operator++ () noexcept(noexcept(++std::declval< underlying_iterator_type & >())) |
Pre-increment operator. | |
constexpr basic_iterator | operator++ (int) noexcept(noexcept(std::declval< underlying_iterator_type & >()++)) |
Post-increment operator. | |
constexpr basic_iterator & | operator-- () noexcept(noexcept(--std::declval< underlying_iterator_type & >())) |
Pre-decrement operator; underlying_iterator_type must model std::bidirectional_iterator. | |
constexpr basic_iterator | operator-- (int) noexcept(noexcept(std::declval< underlying_iterator_type & >() --)) |
Post-decrement operator; underlying_iterator_type must model std::bidirectional_iterator. | |
constexpr basic_iterator & | operator+= (difference_type const offset) noexcept(noexcept(std::declval< basic_iterator & >().from_index(1))) |
Advances the iterator by the given offset; underlying_iterator_type must model \ std::random_access_iterator. | |
constexpr basic_iterator | operator+ (difference_type const offset) const noexcept(noexcept(std::declval< basic_iterator & >()+=1)) |
Advances the iterator by the given offset; underlying_iterator_type must model \ std::random_access_iterator. | |
constexpr basic_iterator & | operator-= (difference_type const offset) noexcept(noexcept(std::declval< basic_iterator & >().from_index(1))) |
Decrements the iterator by the given offset; underlying_iterator_type must model \ std::random_access_iterator. | |
constexpr basic_iterator | operator- (difference_type const offset) const noexcept(noexcept(std::declval< basic_iterator & >() -=1)) |
Decrements the iterator by the given offset; underlying_iterator_type must model \ std::random_access_iterator. | |
template<typename other_range_type > requires std::random_access_iterator<underlying_iterator_type> && std::same_as<std::remove_const_t<range_type>, std::remove_const_t<other_range_type>> | |
constexpr difference_type | operator- (basic_iterator< other_range_type > const &rhs) const noexcept(noexcept(std::declval< basic_iterator & >().to_index())) |
Computes the distance between two iterators; underlying_iterator_type must model \ std::random_access_iterator. | |
The forward declared iterator type for pairwise_combine_view.
The internal iterator type for pairwise_combine_view.
range_type | The type of the range this iterator is operating on. |
This iterator models the iterator category of the underlying_iterator_type
. It maintains a pair of iterators on the underlying range that move over all pairwise combinations of elements. The end is reached, when the second iterator points to the end of the underlying range and the first iterator to the last element of the range. Also note that this iterator does not model Cpp17Iterator, since it does not return a reference to the represented type but a prvalue. Thus this iterator might not be usable with some legacy algorithms of the STL. But it is guaranteed to work with the ranges algorithms.
|
no-apiinlineconstexprnoexcept |
Constructs the iterator from the current underlying iterator and the end iterator of the underlying range.
[in] | iter | The iterator pointing to current element within the underlying range. |
[in] | begin_it | The iterator pointing to begin of the underlying range. Only needed if underlying_iterator_type models std::random_access_iterator. |
[in] | end_it | The iterator pointing to end of the underlying range. |
Constructs the iterator by caching the end of the underlying range and setting the first iterator to the given position and the second to the first incremented by one.
|
no-apiinlineconstexprnoexcept |
Constructs const iterator from non-const iterator.
[in] | other | The non-const iterator to construct from. |
Allows construction of a const iterator (operating on a const range) from a non-const iterator. This special constructor is needed as it is not covered by the standard copy and move constructors.
|
no-apiinlineconstexprprivatenoexcept |
Sets the iterator to the given index.
[in] | index | The index to set the iterator to. |
The pairwise combination can also be seen as a triangular matrix, where given a size n the corresponding matrix has values in [0, 1], [0, 2], ... , [0, n - 1], [1, 2], ..., [1, n - 1], ... [n - 2, n - 1] and all other entries are empty. Using this scheme one can use the properties of triangular numbers, where the diagonal index of this matrix can be computed using triangular roots (see https://stackoverflow.com/questions/27086195/linear-index-upper-triangular-matrix). Given these properties, one can compute the matrix index (i, j) from the linearised matrix index and vice versa.
|
no-apiinlineconstexprnoexcept |
Access the element at the given index.
[in] | index | The index of the element to be returned. |
|
no-apiinlineconstexprprivatenoexcept |
Returns the index for the current iterator position.
The pairwise combination can also be seen as a triangular matrix, where given a size n the corresponding matrix has values in [0, 1], [0, 2], ... , [0, n - 1], [1, 2], ..., [1, n - 1], ... [n - 2, n - 1] and all other entries are empty. Using this scheme one can use the properties of triangular numbers, where the diagonal index of this matrix can be computed using triangular roots (see https://stackoverflow.com/questions/27086195/linear-index-upper-triangular-matrix). Given these properties, one can compute the matrix index (i, j) from the linearised matrix index and vice versa.