SeqAn3 3.4.0-rc.1
The Modern C++ library for sequence analysis.
Loading...
Searching...
No Matches
seqan3::detail::trace_iterator_base< derived_t, matrix_iter_t > Class Template Reference

A CRTP-base class for trace iterator implementations for the alignment algorithms. More...

#include <seqan3/alignment/matrix/detail/trace_iterator_base.hpp>

+ Inheritance diagram for seqan3::detail::trace_iterator_base< derived_t, matrix_iter_t >:

Public Types

Associated types
using value_type = trace_directions
 The value type.
 
using reference = trace_directions const &
 The reference type.
 
using pointer = value_type const *
 The pointer type.
 
using difference_type = std::ptrdiff_t
 The difference type.
 
using iterator_category = std::forward_iterator_tag
 

Public Member Functions

Element access
reference operator* () const noexcept
 Returns the current trace direction.
 
pointer operator-> () const noexcept
 Returns a pointer to the current trace direction.
 
constexpr matrix_coordinate coordinate () const noexcept
 Returns the current coordinate in two-dimensional space.
 
Arithmetic operators
constexpr derived_toperator++ () noexcept
 Advances the iterator by one.
 
constexpr derived_t operator++ (int) noexcept
 Returns an iterator advanced by one.
 

Private Member Functions

constexpr derived_t const & derived () const noexcept
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
constexpr derived_tderived () noexcept
 Cast this object to its derived type.
 
void set_trace_direction (trace_directions const dir) noexcept
 Updates the current trace direction.
 
Constructors, destructor and assignment
constexpr trace_iterator_base ()=default
 Defaulted.
 
constexpr trace_iterator_base (trace_iterator_base const &)=default
 Defaulted.
 
constexpr trace_iterator_base (trace_iterator_base &&)=default
 Defaulted.
 
constexpr trace_iterator_baseoperator= (trace_iterator_base const &)=default
 Defaulted.
 
constexpr trace_iterator_baseoperator= (trace_iterator_base &&)=default
 Defaulted.
 
 ~trace_iterator_base ()=default
 Defaulted.
 
constexpr trace_iterator_base (matrix_iter_t const matrix_iter) noexcept
 Constructs from the underlying trace matrix iterator indicating the start of the trace path.
 
template<typename other_derived_t , two_dimensional_matrix_iterator other_matrix_iter_t>
requires std::constructible_from<matrix_iter_t, other_matrix_iter_t>
constexpr trace_iterator_base (trace_iterator_base< other_derived_t, other_matrix_iter_t > const &other) noexcept
 Constructs from the underlying trace matrix iterator indicating the start of the trace path.
 
Overload functions

These functions can be overloaded by the derived class to customise the iterator.

constexpr void go_left (matrix_iter_t &iter) const noexcept
 Moves iterator to previous left cell.
 
constexpr void go_up (matrix_iter_t &iter) const noexcept
 Moves iterator to previous up cell.
 
constexpr void go_diagonal (matrix_iter_t &iter) const noexcept
 Moves iterator to previous diagonal cell.
 

Private Attributes

trace_directions current_direction {}
 The current trace direction.
 
friend derived_t
 Befriend the derived iterator class to allow calling the private constructors.
 
matrix_iter_t matrix_iter {}
 The underlying matrix iterator.
 

Friends

template<typename other_derived_t , two_dimensional_matrix_iterator other_matrix_iter_t>
class trace_iterator_base
 Befriend with corresponding const_iterator.
 
Comparison operators
constexpr friend bool operator== (derived_t const &lhs, derived_t const &rhs) noexcept
 Returns true if both iterators are equal, false otherwise.
 
constexpr friend bool operator== (derived_t const &lhs, std::default_sentinel_t const &) noexcept
 Returns true if the pointed-to-element is seqan3::detail::trace_directions::none.
 
constexpr friend bool operator== (std::default_sentinel_t const &, derived_t const &rhs) noexcept
 copydoc operator==()
 
constexpr friend bool operator!= (derived_t const &lhs, derived_t const &rhs) noexcept
 Returns true if both iterators are not equal, false otherwise.
 
constexpr friend bool operator!= (derived_t const &lhs, std::default_sentinel_t const &) noexcept
 Returns true if the pointed-to-element is not seqan3::detail::trace_directions::none.
 
constexpr friend bool operator!= (std::default_sentinel_t const &, derived_t const &rhs) noexcept
 copydoc operator!=()
 

Detailed Description

template<typename derived_t, two_dimensional_matrix_iterator matrix_iter_t>
class seqan3::detail::trace_iterator_base< derived_t, matrix_iter_t >

A CRTP-base class for trace iterator implementations for the alignment algorithms.

Template Parameters
derived_tThe derived iterator type.
matrix_iter_tThe wrapped matrix iterator; must model seqan3::detail::two_dimensional_matrix_iterator and the iterator's value type must be the same as seqan3::detail::trace_directions, i.e. std::same_as<std::iter_value_t<matrix_iter_t>, trace_directions> must evaluate to true.

This iterator follows the trace path generated by the alignment algorithm. It wraps an underlying seqan3::detail::two_dimensional_matrix_iterator over a trace matrix, whose value type is seqan3::detail::trace_directions. The iterator moves along the trace path until it finds a cell with seqan3::detail::trace_directions::none. Accordingly, when advancing this iterator, it actually moves from right to left and from bottom to top in the underlying matrix. When the iterator is dereferenced, it outputs any of the following direction: seqan3::detail::trace_directions::diagonal, seqan3::detail::trace_directions::up, or seqan3::detail::trace_directions::left.

In addition, the iterator provides an additional member to access the current position as a seqan3::detail::matrix_coordinate.

This iterator also models the Cpp17ForwardIterator. Note, it does not directly dereference the actual trace direction stored in the underlying matrix. Thus, it cannot be used as an output iterator.

Overloading the behaviour

The behaviour of following a trace direction can be customised through the derived type by overloading the functions

In the default implementation they move along an unbanded matrix. This means, they go to the previous cell in the respective direction.

Member Typedef Documentation

◆ iterator_category

template<typename derived_t , two_dimensional_matrix_iterator matrix_iter_t>
using seqan3::detail::trace_iterator_base< derived_t, matrix_iter_t >::iterator_category = std::forward_iterator_tag

Forward iterator tag.

Constructor & Destructor Documentation

◆ trace_iterator_base() [1/2]

template<typename derived_t , two_dimensional_matrix_iterator matrix_iter_t>
constexpr seqan3::detail::trace_iterator_base< derived_t, matrix_iter_t >::trace_iterator_base ( matrix_iter_t const  matrix_iter)
inlineconstexprprivatenoexcept

Constructs from the underlying trace matrix iterator indicating the start of the trace path.

Parameters
[in]matrix_iterThe underlying matrix iterator.

◆ trace_iterator_base() [2/2]

template<typename derived_t , two_dimensional_matrix_iterator matrix_iter_t>
template<typename other_derived_t , two_dimensional_matrix_iterator other_matrix_iter_t>
requires std::constructible_from<matrix_iter_t, other_matrix_iter_t>
constexpr seqan3::detail::trace_iterator_base< derived_t, matrix_iter_t >::trace_iterator_base ( trace_iterator_base< other_derived_t, other_matrix_iter_t > const &  other)
inlineconstexprprivatenoexcept

Constructs from the underlying trace matrix iterator indicating the start of the trace path.

Template Parameters
other_matrix_iter_tThe underlying matrix iterator type of other; the condition std::constructible_from<matrix_iter_t, other_matrix_iter_t> must evaluate to true.
Parameters
[in]otherThe underlying matrix iterator.

Allows the conversion of non-const to const iterator.


The documentation for this class was generated from the following file:
Hide me