rangeless::fn
Grouping

Functions

template<typename F >
impl::group_all_by< F > rangeless::fn::group_all_by (F key_fn)
 Similar to group_adjacent_by, but presorts the elements. More...
 
impl::group_all_by< by::identityrangeless::fn::group_all ()
 
template<typename F >
impl::group_adjacent_by< F > rangeless::fn::group_adjacent_by (F key_fn)
 Group adjacent elements. More...
 
template<typename F >
impl::group_adjacent_as_subseqs_by< F > rangeless::fn::group_adjacent_by (F key_fn, impl::to_seq)
 Group adjacent elements. More...
 
impl::group_adjacent_by< by::identityrangeless::fn::group_adjacent ()
 
impl::group_adjacent_as_subseqs_by< by::identityrangeless::fn::group_adjacent (impl::to_seq)
 
template<typename BinaryPred >
impl::group_adjacent_by< fn::by::identity, BinaryPred > rangeless::fn::group_adjacent_if (BinaryPred pred2)
 Group adjacent elements if binary predicate holds. More...
 
template<typename BinaryPred >
impl::group_adjacent_as_subseqs_by< fn::by::identity, BinaryPred > rangeless::fn::group_adjacent_if (BinaryPred pred2, impl::to_seq)
 Group adjacent elements if binary predicate holds. More...
 
impl::group_adjacent_by< impl::chunkerrangeless::fn::in_groups_of (size_t n)
 Group adjacent elements into chunks of specified size. More...
 

Detailed Description

Function Documentation

◆ group_adjacent() [1/2]

impl::group_adjacent_by<by::identity> rangeless::fn::group_adjacent ( )
inline

Definition at line 4093 of file fn.hpp.

◆ group_adjacent() [2/2]

impl::group_adjacent_as_subseqs_by<by::identity> rangeless::fn::group_adjacent ( impl::to_seq  )
inline

Definition at line 4098 of file fn.hpp.

◆ group_adjacent_by() [1/2]

template<typename F >
impl::group_adjacent_by<F> rangeless::fn::group_adjacent_by ( key_fn)

Group adjacent elements.

See also
group_all_by
concat

If arg is a container, works similar to group_all_by, except returns a std::vector<Cont> where each container contains adjacently-equal elements having same value of key.

If arg is a seq<...>, composes a seq<...> that shall yield vector<value_type>s having same value of key. (NB: if the value_type is a char, the group-type is std::string).

Buffering space requirements for seq: O(max-groupsize).

Definition at line 4059 of file fn.hpp.

◆ group_adjacent_by() [2/2]

template<typename F >
impl::group_adjacent_as_subseqs_by<F> rangeless::fn::group_adjacent_by ( key_fn,
impl::to_seq   
)

Group adjacent elements.

This is similar to regular group_adjacent_by, except the result type is a seq yielding subseqs of equivalent elements, rather than vectors.

fn::seq(...)
% fn::for_each([&](auto group_seq) // type of group_seq is a seq<...> instead of vector<...>
{
for(auto elem : group_seq) {
// ...
}
});

This is useful for cases where a subseq can be arbitrarily large, and you want to process grouped elements on-the-fly without accumulating them in a vector.

This comes at the cost of more constrained functionality, since all groups and all elements in each group can only be accessed once and in order.

Definition at line 4086 of file fn.hpp.

◆ group_adjacent_if() [1/2]

template<typename BinaryPred >
impl::group_adjacent_by<fn::by::identity, BinaryPred> rangeless::fn::group_adjacent_if ( BinaryPred  pred2)

Group adjacent elements if binary predicate holds.

Definition at line 4107 of file fn.hpp.

◆ group_adjacent_if() [2/2]

template<typename BinaryPred >
impl::group_adjacent_as_subseqs_by<fn::by::identity, BinaryPred> rangeless::fn::group_adjacent_if ( BinaryPred  pred2,
impl::to_seq   
)

Group adjacent elements if binary predicate holds.

Definition at line 4114 of file fn.hpp.

◆ group_all()

impl::group_all_by<by::identity> rangeless::fn::group_all ( )
inline

Definition at line 4038 of file fn.hpp.

◆ group_all_by()

template<typename F >
impl::group_all_by<F> rangeless::fn::group_all_by ( key_fn)

Similar to group_adjacent_by, but presorts the elements.

See also
group_adjacent_by
using alns_t = std::vector<CRef<CSeq_align>>;
std::move(alignments)
% fn::group_all_by([&](CConstRef<CSeq_align> aln)
{
return GetLocusId( aln->GetSeq_id(0) );
})
% fn::for_each([&](alns_t alns)
{
// Process alignments for a locus...
});
Note: template<typename Cont> impl::group_all_by<F>::operator()(Cont inputs)
takes Cont by-value and moves elements into the output.

Buffering space requirements for seq: O(N).

Definition at line 4033 of file fn.hpp.

◆ in_groups_of()

impl::group_adjacent_by<impl::chunker> rangeless::fn::in_groups_of ( size_t  n)
inline

Group adjacent elements into chunks of specified size.

std::move(elems)
% fn::for_each(auto&& group)
{
ASSERT(group.size() <= 5);
});

Buffering space requirements for seq: O(n).

Definition at line 4135 of file fn.hpp.