rangeless::fn
Ordering

Functions

impl::reverse rangeless::fn::reverse ()
 Reverse the elements in the input container. More...
 
template<typename F >
impl::sort_by< F, impl::stable_sort_tagrangeless::fn::sort_by (F key_fn)
 stable-sort and return the input. More...
 
impl::sort_by< by::identity, impl::stable_sort_tagrangeless::fn::sort ()
 sort_by with key_fn = by::identity More...
 
template<typename F >
impl::sort_by< F, impl::unstable_sort_tagrangeless::fn::unstable_sort_by (F key_fn)
 
impl::sort_by< by::identity, impl::unstable_sort_tagrangeless::fn::unstable_sort ()
 
template<typename F >
impl::lazy_sort_by< F > rangeless::fn::lazy_sort_by (F key_fn)
 Unstable lazy sort. More...
 
impl::lazy_sort_by< by::identityrangeless::fn::lazy_sort ()
 lazy_sort_by with key_fn = by::identity More...
 
template<typename F >
impl::take_top_n_by< F > rangeless::fn::take_top_n_by (size_t n, F key_fn)
 Return top-n elements, sorted by key_fn. More...
 
impl::take_top_n_by< by::identityrangeless::fn::take_top_n (size_t n)
 Return top-n elements, sorted by identity. More...
 

Detailed Description

Function Documentation

◆ lazy_sort()

impl::lazy_sort_by<by::identity> rangeless::fn::lazy_sort ( )
inline

lazy_sort_by with key_fn = by::identity

Definition at line 4213 of file fn.hpp.

◆ lazy_sort_by()

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

Unstable lazy sort.

Initially move all inputs into a std::vector and heapify in O(n), and then lazily yield elements with pop_heap in O(log(n)). This is more efficient if the downstream stage is expected to consume a small fraction of sorted inputs.

Buffering space requirements for seq: O(N).

Definition at line 4207 of file fn.hpp.

◆ reverse()

impl::reverse rangeless::fn::reverse ( )
inline

Reverse the elements in the input container.

Buffering space requirements for seq: O(N).

Definition at line 4151 of file fn.hpp.

◆ sort()

impl::sort_by<by::identity, impl::stable_sort_tag> rangeless::fn::sort ( )
inline

sort_by with key_fn = by::identity

Definition at line 4180 of file fn.hpp.

◆ sort_by()

template<typename F >
impl::sort_by<F, impl::stable_sort_tag> rangeless::fn::sort_by ( key_fn)

stable-sort and return the input.

auto res =
std::list<std::string>{{ "333", "1", "22", "333", "22" }}
% fn::sort_by([](const std::string& s)
{
return fn::by::decreasing(s.size());
})
VERIFY(( res == std::vector<std::string>{{ "333", "22", "1" }} ));

Buffering space requirements for seq: O(N).

Definition at line 4174 of file fn.hpp.

◆ take_top_n()

impl::take_top_n_by<by::identity> rangeless::fn::take_top_n ( size_t  n)
inline

Return top-n elements, sorted by identity.

Definition at line 4232 of file fn.hpp.

◆ take_top_n_by()

template<typename F >
impl::take_top_n_by<F> rangeless::fn::take_top_n_by ( size_t  n,
key_fn 
)

Return top-n elements, sorted by key_fn.

This is conceptually similar to fn::sort_by(key_fn) % fn::take_last(n), but is more efficient: the implementation mantains a priority-queue of top-n max-elements encountered so-far.

Buffering space requirements: O(n); time complexity: O(N*log(n))

Definition at line 4226 of file fn.hpp.

◆ unstable_sort()

impl::sort_by<by::identity, impl::unstable_sort_tag> rangeless::fn::unstable_sort ( )
inline

Definition at line 4192 of file fn.hpp.

◆ unstable_sort_by()

template<typename F >
impl::sort_by<F, impl::unstable_sort_tag> rangeless::fn::unstable_sort_by ( key_fn)

Definition at line 4187 of file fn.hpp.