SeqAn3 3.2.0-rc.1
The Modern C++ library for sequence analysis.
seqan3::detail::chunk_view< urng_t >::basic_iterator< const_range > Class Template Reference

Iterator for dividing an forward range into chunks. More...

#include <seqan3/utility/views/chunk.hpp>

+ Inheritance diagram for seqan3::detail::chunk_view< urng_t >::basic_iterator< const_range >:

Public Types

Associated types
using difference_type = typename std::iter_difference_t< it_t >
 Type for distances between iterators.
 
using value_type = std::ranges::subrange< it_t, it_t >
 Value type of this iterator.
 
using pointer = void
 The pointer type.
 
using reference = value_type
 Same as value_type.
 
using iterator_concept = std::conditional_t< std::contiguous_iterator< it_t >, typename std::random_access_iterator_tag, detail::iterator_concept_tag_t< it_t > >
 Tag this class depending on which concept it_t models.
 
- Public Types inherited from seqan3::detail::maybe_iterator_category< maybe_const_iterator_t< const_range, urng_t > >
using iterator_category = MAYBE_PRESENT(std::iterator_traits< maybe_const_iterator_t< const_range, urng_t > >::iterator_category)
 The iterator category tag. (not always present!) More...
 

Public Member Functions

constexpr value_type operator* () const noexcept
 Return the current chunk, e.g the current subrange.
 
constexpr basic_iterator operator+ (difference_type const skip) const noexcept
 Forward copy of this iterator. More...
 
constexpr basic_iteratoroperator++ () noexcept
 Pre-increment.
 
basic_iterator operator++ (int) noexcept
 Post-increment.
 
constexpr basic_iteratoroperator+= (difference_type const skip) noexcept
 Forward this iterator. More...
 
constexpr basic_iterator operator- (difference_type const skip) const noexcept
 Return decremented copy of this iterator. More...
 
constexpr basic_iteratoroperator-- () noexcept
 Pre-decrement. More...
 
constexpr basic_iterator operator-- (int) noexcept
 Post-decrement. More...
 
constexpr basic_iteratoroperator-= (difference_type const skip) noexcept
 Decrement iterator by skip. More...
 
constexpr reference operator[] (difference_type const n) const
 Move the iterator by a given offset and return the corresponding chunk (subrange). More...
 
Constructors, destructor and assignment
constexpr basic_iterator ()=default
 Defaulted.
 
constexpr basic_iterator (basic_iterator const &)=default
 Defaulted.
 
constexpr basic_iterator (basic_iterator &&)=default
 Defaulted.
 
constexpr basic_iteratoroperator= (basic_iterator const &)=default
 Defaulted.
 
constexpr basic_iteratoroperator= (basic_iterator &&)=default
 Defaulted.
 
 ~basic_iterator ()=default
 Defaulted.
 
constexpr basic_iterator (basic_iterator<!const_range > const &it) noexcept
 Allow iterator on a const range to be constructible from an iterator over a non-const range.
 
constexpr basic_iterator (it_t it_start, sentinel_t it_end, uint16_t const size_of_chunk)
 Construct from the start and end of the underlying range and a chunk size. /param[in] it_start Iterator pointing to the first position of the underlying range. /param[in] it_end Sentinel pointing to the end of the underlying range. /param[in] size_of_chunk The chunk size, e.g. the length of the subrange returned by this iterator. More...
 

Private Types

using it_t = maybe_const_iterator_t< const_range, urng_t >
 The iterator type of the underlying range.
 
using sentinel_t = maybe_const_sentinel_t< const_range, urng_t >
 The sentinel type of the underlying range.
 

Private Member Functions

constexpr it_t get_former_start_of_chunk (it_t end_of_chunk) const
 Move to the start of the former chunk.
 
constexpr it_t get_next_end_of_chunk (it_t start_of_chunk) const
 Move to the end of the next chunk.
 

Private Attributes

uint16_t chunk_size
 The chunk size, e.g. the length of the subrange returned by this iterator.
 
value_type current_chunk
 The current chunk stored as a subrange.
 
it_t urng_begin
 Points to the start of the underlying range.
 
sentinel_t urng_end
 Points to the end of the underlying range.
 

Friends

constexpr basic_iterator operator+ (difference_type const skip, basic_iterator const &it) noexcept
 Non-member operator+ delegates to non-friend operator+. More...
 
constexpr difference_type operator- (basic_iterator const &lhs, basic_iterator const &rhs) noexcept
 Return offset between two iterator's positions. More...
 
constexpr difference_type operator- (basic_iterator const &lhs, sentinel_t const &rhs) noexcept
 Return offset this and remote sentinel's position. More...
 
constexpr basic_iterator operator- (difference_type const skip, basic_iterator const &it) noexcept
 Non-member operator- delegates to non-friend operator-. More...
 
constexpr difference_type operator- (sentinel_t const &, basic_iterator const &rhs) noexcept
 Return offset between remote sentinel's position and this. More...
 
Comparison operators

constexpr bool operator== (basic_iterator const &lhs, sentinel_t const &rhs) noexcept
 Compare to end of underlying range.
 
constexpr bool operator== (basic_iterator const &lhs, basic_iterator const &rhs) noexcept
 Compare to another basic_iterator.
 
constexpr bool operator!= (basic_iterator const &lhs, sentinel_t const &rhs) noexcept
 Compare to underlying range sentinel type.
 
constexpr bool operator!= (basic_iterator const &lhs, basic_iterator const &rhs) noexcept
 Compare to another basic_iterator.
 
constexpr bool operator< (basic_iterator const &lhs, basic_iterator const &rhs) noexcept
 Compare to another basic_iterator.
 
constexpr bool operator> (basic_iterator const &lhs, basic_iterator const &rhs) noexcept
 Compare to another basic_iterator.
 
constexpr bool operator<= (basic_iterator const &lhs, basic_iterator const &rhs) noexcept
 Compare to another basic_iterator.
 
constexpr bool operator>= (basic_iterator const &lhs, basic_iterator const &rhs) noexcept
 Compare to another basic_iterator.
 

Detailed Description

template<std::ranges::input_range urng_t>
template<bool const_range>
requires std::ranges::view<urng_t>
class seqan3::detail::chunk_view< urng_t >::basic_iterator< const_range >

Iterator for dividing an forward range into chunks.

Template Parameters
urng_tThe type of the underlying range. Must model std::ranges::view and std::forward_range.

The basic_iterator can be used to iterate over an underlying forward range in chunks. It holds the start and end iterator of the underlying range, the chunk size and the subrange of the current chunk. The current chunk is represented by a subrange on the underlying range.

Concept modelled by passed text iterator Available functions
std::forward_iterator Comparison operators
Pre-increment (++it)
Post-increment (it++)
Indirection operator (*it)
std::bidirectional_iterator Pre-decrement (--it)
Post-decrement (it--)
std::random_access_iterator Forward (it +=)
Forward copy (it +)
Decrement(it -=)
Decrement copy (it -)
Difference (it1 - it2)
Subscript (it[])

Constructor & Destructor Documentation

◆ basic_iterator()

template<std::ranges::input_range urng_t>
template<bool const_range>
constexpr seqan3::detail::chunk_view< urng_t >::basic_iterator< const_range >::basic_iterator ( it_t  it_start,
sentinel_t  it_end,
uint16_t const  size_of_chunk 
)
inlineexplicitconstexpr

Construct from the start and end of the underlying range and a chunk size. /param[in] it_start Iterator pointing to the first position of the underlying range. /param[in] it_end Sentinel pointing to the end of the underlying range. /param[in] size_of_chunk The chunk size, e.g. the length of the subrange returned by this iterator.

Complexity

Linear in chunk_size for non-random_access ranges. Constant else.

Member Function Documentation

◆ operator+()

template<std::ranges::input_range urng_t>
template<bool const_range>
constexpr basic_iterator seqan3::detail::chunk_view< urng_t >::basic_iterator< const_range >::operator+ ( difference_type const  skip) const
inlineconstexprnoexcept

Forward copy of this iterator.

Attention
This function is only available if it_t models std::random_access_iterator.

◆ operator+=()

template<std::ranges::input_range urng_t>
template<bool const_range>
constexpr basic_iterator & seqan3::detail::chunk_view< urng_t >::basic_iterator< const_range >::operator+= ( difference_type const  skip)
inlineconstexprnoexcept

Forward this iterator.

Attention
This function is only available if it_t models std::random_access_iterator.

◆ operator-()

template<std::ranges::input_range urng_t>
template<bool const_range>
constexpr basic_iterator seqan3::detail::chunk_view< urng_t >::basic_iterator< const_range >::operator- ( difference_type const  skip) const
inlineconstexprnoexcept

Return decremented copy of this iterator.

Attention
This function is only available if it_t models std::random_access_iterator.

◆ operator--() [1/2]

template<std::ranges::input_range urng_t>
template<bool const_range>
constexpr basic_iterator & seqan3::detail::chunk_view< urng_t >::basic_iterator< const_range >::operator-- ( )
inlineconstexprnoexcept

Pre-decrement.

Attention
This function is only available if it_t models std::bidirectional_iterator.

◆ operator--() [2/2]

template<std::ranges::input_range urng_t>
template<bool const_range>
constexpr basic_iterator seqan3::detail::chunk_view< urng_t >::basic_iterator< const_range >::operator-- ( int  )
inlineconstexprnoexcept

Post-decrement.

Attention
This function is only available if it_t models std::bidirectional_iterator.

◆ operator-=()

template<std::ranges::input_range urng_t>
template<bool const_range>
constexpr basic_iterator & seqan3::detail::chunk_view< urng_t >::basic_iterator< const_range >::operator-= ( difference_type const  skip)
inlineconstexprnoexcept

Decrement iterator by skip.

Attention
This function is only available if it_t models std::random_access_iterator.

◆ operator[]()

template<std::ranges::input_range urng_t>
template<bool const_range>
constexpr reference seqan3::detail::chunk_view< urng_t >::basic_iterator< const_range >::operator[] ( difference_type const  n) const
inlineconstexpr

Move the iterator by a given offset and return the corresponding chunk (subrange).

Attention
This function is only available if it_t models std::random_access_iterator.

Friends And Related Function Documentation

◆ operator+

template<std::ranges::input_range urng_t>
template<bool const_range>
constexpr basic_iterator operator+ ( difference_type const  skip,
basic_iterator< const_range > const &  it 
)
friend

Non-member operator+ delegates to non-friend operator+.

Attention
This function is only available if it_t models std::random_access_iterator.

◆ operator- [1/4]

template<std::ranges::input_range urng_t>
template<bool const_range>
constexpr difference_type operator- ( basic_iterator< const_range > const &  lhs,
basic_iterator< const_range > const &  rhs 
)
friend

Return offset between two iterator's positions.

operator-difference

Attention
This function is only available if it_t models std::sized_sentinel_for<it_t, it_t>.

◆ operator- [2/4]

template<std::ranges::input_range urng_t>
template<bool const_range>
constexpr difference_type operator- ( basic_iterator< const_range > const &  lhs,
sentinel_t const &  rhs 
)
friend

Return offset this and remote sentinel's position.

Attention
This function is only available if it_t and sentinel_t model std::sized_sentinel_for.

◆ operator- [3/4]

template<std::ranges::input_range urng_t>
template<bool const_range>
constexpr basic_iterator operator- ( difference_type const  skip,
basic_iterator< const_range > const &  it 
)
friend

Non-member operator- delegates to non-friend operator-.

Attention
This function is only available if it_t models std::random_access_iterator.

◆ operator- [4/4]

template<std::ranges::input_range urng_t>
template<bool const_range>
constexpr difference_type operator- ( sentinel_t const &  ,
basic_iterator< const_range > const &  rhs 
)
friend

Return offset between remote sentinel's position and this.

Attention
This function is only available if sentinel_t and it_t model std::sized_sentinel_for.

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