SeqAn3
View

Standard library views. More...

Collaboration diagram for View:

Typedefs

template<std::Iterator it_t, std::Sentinel< it_t > sen_t>
using seqan3::view::subrange = std::ranges::iterator_range< it_t, sen_t >
 Create a view from a pair of iterator and sentinel. More...
 

Variables

constexpr auto seqan3::view::all
 A view that safely wraps a container (you will likely not need to use this unless defining a new view). More...
 
constexpr auto seqan3::view::common
 A range adaptor that makes any range satisfy std::ranges::CommonRange (at the expense of some performance). More...
 
constexpr auto seqan3::view::filter
 A range adaptor that takes a predicate and returns a view of the elements that satisfy the predicate. More...
 
constexpr auto seqan3::view::reverse
 A range adaptor that presents the underlying range in reverse order. More...
 
constexpr auto seqan3::view::transform
 A range adaptor that takes a invocable and returns a view of the elements with the invocable applied. More...
 

Detailed Description

Standard library views.

Todo:
write me.

Typedef Documentation

◆ subrange

template<std::Iterator it_t, std::Sentinel< it_t > sen_t>
using seqan3::view::subrange = typedef std::ranges::iterator_range<it_t, sen_t>

Create a view from a pair of iterator and sentinel.

Template Parameters
it_tType of the iterator; must satisfy std::Iterator.
sen_tType of the sentinel; must satisfy std::Sentinel with it_t.
Parameters
[in]itThe iterator on the underlying range.
[in]senThe sentinel on the underlying range
Returns
A view of the elements between it_t and sen_t.

View properties

This view is source-only, it can only be at the beginning of a pipe of range transformations.

range concepts and reference_t rrng_t (returned range type)
std::ranges::InputRange preserved
std::ranges::ForwardRange preserved
std::ranges::BidirectionalRange preserved
std::ranges::RandomAccessRange preserved
std::ranges::ContiguousRange preserved
std::ranges::ViewableRange guaranteed
std::ranges::View guaranteed
std::ranges::SizedRange preserved
std::ranges::CommonRange preserved
std::ranges::OutputRange preserved
seqan3::const_iterable_concept preserved
seqan3::reference_t seqan3::value_type_t<it_t>

Preservation in this table refers to the properties of the iterator/sentinel pair.

See the view submodule documentation for detailed descriptions of the view properties.

STD module

This entity will likely be part of C++20 or C++23. It's API will track current proposals and not be stable within SeqAn3 releases. It is implemented via the range-v3 library or the standard library (if available). Should it become clear that it will not become part of a future standard, it will migrate to a regular SeqAn3 module.

Example

dna4_vector s{"ACTTTGATAA"_dna4};
using iterator = dna4_vector::iterator;
auto v1 = view::subrange<iterator, iterator>{begin(s) + 2, end(s)} | view::to_char; // == "TTTGATAA"

Variable Documentation

◆ all

constexpr auto seqan3::view::all
inline

A view that safely wraps a container (you will likely not need to use this unless defining a new view).

Template Parameters
urng_tThe type of the range being processed. See below for requirements.
Parameters
[in]urangeThe range being processed.
Returns
A view over the elements of the underlying range.

View properties

This view is source-only, it can only be at the beginning of a pipe of range transformations. The "underlying range" refers to the mandatory parameter of this adaptor, not a previous range in a pipe.

range concepts and reference_t urng_t (underlying range type) rrng_t (returned range type)
std::ranges::InputRange preserved
std::ranges::ForwardRange preserved
std::ranges::BidirectionalRange preserved
std::ranges::RandomAccessRange preserved
std::ranges::ContiguousRange preserved
std::ranges::ViewableRange required guaranteed
std::ranges::View guaranteed
std::ranges::SizedRange preserved
std::ranges::CommonRange preserved
std::ranges::OutputRange preserved
seqan3::const_iterable_concept preserved
seqan3::reference_t seqan3::reference_t<urng_t>

See the view submodule documentation for detailed descriptions of the view properties.

STD module

This entity will likely be part of C++20 or C++23. It's API will track current proposals and not be stable within SeqAn3 releases. It is implemented via the range-v3 library or the standard library (if available). Should it become clear that it will not become part of a future standard, it will migrate to a regular SeqAn3 module.

Example

dna4_vector s{"ACTTTGATAN"_dna4};
auto v = view::all(s); // the same as view::subrange{begin(s), end(s)}

◆ common

constexpr auto seqan3::view::common
inline

A range adaptor that makes any range satisfy std::ranges::CommonRange (at the expense of some performance).

Template Parameters
urng_tThe type of the range being processed. See below for requirements. [template parameter is omitted in pipe notation]
Parameters
[in]urangeThe range being processed. [parameter is omitted in pipe notation]
Returns
A view of the underlying range that is common – even if the underlying range is not.

View properties

range concepts and reference_t urng_t (underlying range type) rrng_t (returned range type)
std::ranges::InputRange required preserved
std::ranges::ForwardRange preserved
std::ranges::BidirectionalRange preserved
std::ranges::RandomAccessRange preserved
std::ranges::ContiguousRange preserved
std::ranges::ViewableRange required guaranteed
std::ranges::View guaranteed
std::ranges::SizedRange preserved
std::ranges::CommonRange guarenteed
std::ranges::OutputRange preserved
seqan3::const_iterable_concept preserved
seqan3::reference_t seqan3::reference_t<urng_t>

See the view submodule documentation for detailed descriptions of the view properties.

STD module

This entity will likely be part of C++20 or C++23. It's API will track current proposals and not be stable within SeqAn3 releases. It is implemented via the range-v3 library or the standard library (if available). Should it become clear that it will not become part of a future standard, it will migrate to a regular SeqAn3 module.

Example

dna5_vector s{"ACTNTGATAN"_dna5};
auto v1 = s | view::filter([](dna5 const l) { return (l != 'N'_dna5); }); // == "ACTTGATA"_dna5
// this won't work (as of C++17), because std::find expects begin and end to be of the same type:
// auto it = std::find(begin(v1), end(v1), 'G'_dna5);
// this will:
auto v2 = v1 | view::common;
auto it = std::find(begin(v2), end(v2), 'G'_dna5);

◆ filter

constexpr auto seqan3::view::filter
inline

A range adaptor that takes a predicate and returns a view of the elements that satisfy the predicate.

Template Parameters
urng_tThe type of the range being processed. See below for requirements. [template parameter is omitted in pipe notation]
predicate_tThe type of the predicate, must satisfy seqan3::predicate_concept.
Parameters
[in]urangeThe range being processed. [parameter is omitted in pipe notation]
[in,out]predicateThe predicate.
Returns
A range of those elements in the underlying range that satisfy the predicate.

View properties

range concepts and reference_t urng_t (underlying range type) rrng_t (returned range type)
std::ranges::InputRange required preserved
std::ranges::ForwardRange preserved
std::ranges::BidirectionalRange preserved
std::ranges::RandomAccessRange lost
std::ranges::ContiguousRange lost
std::ranges::ViewableRange required guaranteed
std::ranges::View guaranteed
std::ranges::SizedRange lost
std::ranges::CommonRange lost
std::ranges::OutputRange preserved
seqan3::const_iterable_concept lost
seqan3::reference_t seqan3::reference_t<urng_t>

See the view submodule documentation for detailed descriptions of the view properties.

STD module

This entity will likely be part of C++20 or C++23. It's API will track current proposals and not be stable within SeqAn3 releases. It is implemented via the range-v3 library or the standard library (if available). Should it become clear that it will not become part of a future standard, it will migrate to a regular SeqAn3 module.

Example

dna5_vector s{"ACTNTGATAN"_dna5};
auto v1 = s | view::filter([](dna5 const l) { return (l != 'N'_dna5); }); // == "ACTTGATA"_dna5

◆ reverse

constexpr auto seqan3::view::reverse
inline

A range adaptor that presents the underlying range in reverse order.

Template Parameters
urng_tThe type of the range being processed. See below for requirements. [template parameter is omitted in pipe notation]
Parameters
[in]urangeThe range being processed. [parameter is omitted in pipe notation]
Returns
A view of the elements of the underlying range in reverse order.

View properties

range concepts and reference_t urng_t (underlying range type) rrng_t (returned range type)
std::ranges::InputRange required preserved
std::ranges::ForwardRange required preserved
std::ranges::BidirectionalRange required preserved
std::ranges::RandomAccessRange preserved
std::ranges::ContiguousRange lost
std::ranges::ViewableRange required guaranteed
std::ranges::View guaranteed
std::ranges::SizedRange preserved
std::ranges::CommonRange preserved
std::ranges::OutputRange lost
seqan3::const_iterable_concept preserved if std::ranges::CommonRange<urng_t>
seqan3::reference_t seqan3::reference_t<urng_t>

See the view submodule documentation for detailed descriptions of the view properties.

STD module

This entity will likely be part of C++20 or C++23. It's API will track current proposals and not be stable within SeqAn3 releases. It is implemented via the range-v3 library or the standard library (if available). Should it become clear that it will not become part of a future standard, it will migrate to a regular SeqAn3 module.

Example

std::string s{"ACTNTGATAN"};
auto v1 = s | view::reverse; // == "NATAGTNTCA"

◆ transform

constexpr auto seqan3::view::transform
inline

A range adaptor that takes a invocable and returns a view of the elements with the invocable applied.

Template Parameters
urng_tThe type of the range being processed. See below for requirements. [template parameter is omitted in pipe notation]
invocable_tThe type of the invocable, must satisfy std::Invocable.
Parameters
[in]urangeThe range being processed. [parameter is omitted in pipe notation]
[in,out]invocableThe invocable (usually a lambda function).
Returns
A range of the elements produced by applied the invocable to each element in the underlying range.

View properties

range concepts and reference_t urng_t (underlying range type) rrng_t (returned range type)
std::ranges::InputRange required preserved
std::ranges::ForwardRange preserved
std::ranges::BidirectionalRange preserved
std::ranges::RandomAccessRange preserved
std::ranges::ContiguousRange lost
std::ranges::ViewableRange required guaranteed
std::ranges::View guaranteed
std::ranges::SizedRange preserved
std::ranges::CommonRange preserved
std::ranges::OutputRange lost
seqan3::const_iterable_concept preserved
seqan3::reference_t decltype(invocable(seqan3::reference_t<urng_t>{}))

See the view submodule documentation for detailed descriptions of the view properties.

STD module

This entity will likely be part of C++20 or C++23. It's API will track current proposals and not be stable within SeqAn3 releases. It is implemented via the range-v3 library or the standard library (if available). Should it become clear that it will not become part of a future standard, it will migrate to a regular SeqAn3 module.

Example

std::string s{"ACTNTGATAN"};
auto v1 = s | view::transform([](dna4 const l) { return to_char(l); }); // == "ACTNTGATAN"