rangeless::fn
rangeless::fn Namespace Reference

LINQ -like library of higher-order functions for data manipulation. More...

Namespaces

 by
 Common key-functions to use with sort_by/unque_by/group_all_by.
 
 get
 Common transform-functions that can be used as param to fn::transform.
 
 impl
 Implementations for corresponding static functions in fn::
 
 operators
 

Classes

struct  end_seq
 Return fn::end_seq() from input-range generator function to signal end-of-inputs. More...
 
class  view
 A view is just a pair of interators with begin() and end() interface. More...
 

Typedefs

template<typename T >
using any_seq_t = impl::seq< impl::any_gen< T > >
 

Functions

template<typename NullaryInvokable >
impl::seq< impl::catch_end< NullaryInvokable > > seq (NullaryInvokable gen_fn)
 Adapt a generator function as InputRange. More...
 
template<typename Iterable >
impl::seq< impl::refs_gen< Iterable > > refs (Iterable &src)
 Adapt a reference to Iterable as seq yielding reference-wrappers. More...
 
template<typename Iterator >
constexpr view< Iterator > from (Iterator it_beg, Iterator it_end) noexcept
 Create a range-view from a pair of iterators. More...
 
template<typename Iterator >
constexpr view< Iterator > from (std::pair< Iterator, Iterator > p) noexcept
 To enable composability of APIs returning a pair of iterators, e.g. std::equal_range. More...
 
template<typename Iterable , typename Iterator = typename Iterable::iterator>
constexpr view< Iterator > from (Iterable &src) noexcept
 Create a range-view for a container, or an iterable that has begin and end as free functions rather than methods. More...
 
template<typename Iterable , typename Iterator = typename Iterable::const_iterator>
constexpr view< Iterator > from (const Iterable &src) noexcept
 
template<typename Iterable , typename Iterator = typename Iterable::const_iterator>
constexpr view< Iterator > cfrom (const Iterable &src) noexcept
 
template<typename Gen , typename T = typename Gen::value_type>
any_seq_t< T > make_typerased (impl::seq< Gen > seq)
 Type-erase a seq. More...
 
impl::to_vector to_vector ()
 Move elements of an Iterable to std::vector. More...
 
impl::to_seq to_seq ()
 Wrap an Iterable, taken by value, as seq yielding elements by-move. More...
 
template<typename Container >
impl::to< Container > to (Container dest)
 e.g. auto set_of_ints = fn::seq(...) % ... % fn::to(std::set<int>{}); More...
 
impl::counts counts ()
 return map: value_type -> size_t More...
 
template<typename F >
impl::adapt< F > adapt (F fn)
 Create a custom processing-stage function-object. More...
 
template<typename F >
impl::transform< F > transform (F map_fn)
 Create a seq yielding results of applying the transform functions to input-elements. More...
 
template<typename Result , typename Op >
impl::foldl< Result, Op > foldl (Result init, Op binary_op)
 Range-based version of c++20 (copy-free) std::accumulate More...
 
template<typename Op >
impl::foldl_d< Op > foldl_d (Op binary_op)
 Fold-Left-with-Default: this version uses default-initialized value for init. More...
 
template<typename Op >
impl::foldl_1< Op > foldl_1 (Op binary_op)
 Init-free version of foldl (first element is used as init); requires at least one element. More...
 
impl::sliding_window sliding_window (size_t win_size)
 
template<typename F >
impl::for_each< F > for_each (F fn)
 
template<typename F2 >
impl::for_each_adjacent< F2 > for_each_adjacent (F2 fn2)
 
template<typename P >
impl::take_while< P > take_while (P pred)
 Yield elements until pred evaluates to false. More...
 
impl::take_while< impl::call_count_lttake_first (size_t n=1)
 Yield first n elements. More...
 
impl::take_last take_last (size_t n=1)
 Yield last n elements. More...
 
template<typename P >
impl::drop_while< P > drop_while (P pred)
 Drop elements until pred evaluates to false. More...
 
impl::drop_while< impl::call_count_ltdrop_first (size_t n=1)
 Drop first n elements. More...
 
impl::drop_last drop_last (size_t n=1)
 Drop last n elements. More...
 
template<typename P >
impl::where< P > where (P pred)
 Filter elements. More...
 
template<typename SortedForwardRange , typename F >
impl::where< impl::in_sorted_by< SortedForwardRange, F > > where_in_sorted_by (const SortedForwardRange &r, F key_fn)
 
template<typename SortedForwardRange >
impl::where< impl::in_sorted_by< SortedForwardRange, by::identity > > where_in_sorted (const SortedForwardRange &r)
 Intersect with a sorted range. More...
 
template<typename SortedForwardRange , typename F >
impl::where< impl::in_sorted_by< SortedForwardRange, F > > where_not_in_sorted_by (const SortedForwardRange &r, F key_fn)
 
template<typename SortedForwardRange >
impl::where< impl::in_sorted_by< SortedForwardRange, by::identity > > where_not_in_sorted (const SortedForwardRange &r)
 Subtract a sorted range. More...
 
template<typename F >
impl::where_max_by< F > where_max_by (F key_fn)
 Filter elements to those having maximum value of fn. More...
 
impl::where_max_by< by::identitywhere_max ()
 
template<typename F >
impl::where_max_by< F > where_min_by (F key_fn)
 
impl::where_max_by< by::identitywhere_min ()
 
template<typename Pred >
impl::exists_where< Pred > exists_where (Pred p)
 
template<typename F >
impl::group_all_by< F > group_all_by (F key_fn)
 Similar to group_adjacent_by, but presorts the elements. More...
 
impl::group_all_by< by::identitygroup_all ()
 
template<typename F >
impl::group_adjacent_by< F > group_adjacent_by (F key_fn)
 Group adjacent elements. More...
 
template<typename F >
impl::group_adjacent_as_subseqs_by< F > group_adjacent_by (F key_fn, impl::to_seq)
 Group adjacent elements. More...
 
impl::group_adjacent_by< by::identitygroup_adjacent ()
 
impl::group_adjacent_as_subseqs_by< by::identitygroup_adjacent (impl::to_seq)
 
template<typename BinaryPred >
impl::group_adjacent_by< fn::by::identity, BinaryPred > 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 > group_adjacent_if (BinaryPred pred2, impl::to_seq)
 Group adjacent elements if binary predicate holds. More...
 
impl::group_adjacent_by< impl::chunkerin_groups_of (size_t n)
 Group adjacent elements into chunks of specified size. More...
 
impl::reverse reverse ()
 Reverse the elements in the input container. More...
 
template<typename F >
impl::sort_by< F, impl::stable_sort_tagsort_by (F key_fn)
 stable-sort and return the input. More...
 
impl::sort_by< by::identity, impl::stable_sort_tagsort ()
 sort_by with key_fn = by::identity More...
 
template<typename F >
impl::sort_by< F, impl::unstable_sort_tagunstable_sort_by (F key_fn)
 
impl::sort_by< by::identity, impl::unstable_sort_tagunstable_sort ()
 
template<typename F >
impl::lazy_sort_by< F > lazy_sort_by (F key_fn)
 Unstable lazy sort. More...
 
impl::lazy_sort_by< by::identitylazy_sort ()
 lazy_sort_by with key_fn = by::identity More...
 
template<typename F >
impl::take_top_n_by< F > 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::identitytake_top_n (size_t n)
 Return top-n elements, sorted by identity. More...
 
template<typename F >
impl::unique_adjacent_by< F > unique_adjacent_by (F key_fn)
 Keep first element from every adjacently-equal run of elements. More...
 
impl::unique_adjacent_by< by::identityunique_adjacent ()
 
template<typename F >
impl::unique_all_by< F > unique_all_by (F key_fn)
 Uniquefy elements globally, as-if unique_adjacent_by pre-sorted by same key. More...
 
impl::unique_all_by< by::identityunique_all ()
 
impl::concat concat ()
 Flatten the result of group_all_by or group_adjacent_by. More...
 
template<typename Iterable >
impl::append< Iterable > append (Iterable next)
 Yield elements of next after elements of arg. More...
 
template<typename Iterable , typename BinaryFn >
impl::zip_with< Iterable, BinaryFn > zip_with (Iterable second, BinaryFn fn)
 Yield pairs of elements, (up to end of the shorter range) More...
 
template<typename BinaryFn >
impl::zip_adjacent< BinaryFn > zip_adjacent (BinaryFn fn)
 Yield invocations of fn over pairs of adjacent inputs. More...
 
template<typename Iterable , typename BinaryFn >
impl::cartesian_product_with< Iterable, BinaryFn > cartesian_product_with (Iterable second, BinaryFn fn)
 
template<typename Container , typename P >
auto get_unique (Container &container, P &&pred) -> decltype(*container.begin())
 Access unique element matching the predicate. More...
 
template<typename Container , typename P , typename Construct >
auto set_unique (Container &container, P &&pred, Construct &&con) -> decltype(*container.begin())
 Similar to get_unique, but end-insert an element if missing. More...
 
template<typename Container >
auto first_or_default (const Container &c) -> typename Container::value_type
 e.g. const CConstRef<CSeq_align> aln = first_or_default( get_alns_annot(...)->Get() ); More...
 
template<typename Container , typename Pred >
auto first_or_default (const Container &c, Pred &&pred) -> typename Container::value_type
 
template<typename Container >
auto last_or_default (const Container &c) -> typename Container::value_type
 
template<typename Container , typename Pred >
auto last_or_default (const Container &c, Pred &&pred) -> typename Container::value_type
 
template<typename F >
impl::memoizer< F > make_memoized (F fn)
 Memoizing wrapper for non-recursive non-mutable unary lambdas (not synchronized). More...
 
template<typename F >
impl::scope_guard< F > make_scope_guard (F fn)
 Basic scope guard - execute some code in guard`s destructor. More...
 
impl::async_wr to_async (size_t queue_size=16)
 Wrap generating seq in an async-task. More...
 
template<typename F >
impl::par_transform< F, impl::std_asynctransform_in_parallel (F map_fn)
 Parallelized version of fn::transform More...
 
template<typename F , typename Async >
impl::par_transform< F, Async > transform_in_parallel (F map_fn, Async async)
 A version of transform_in_parallel that uses a user-provided Async (e.g. backed by a fancy work-stealing thread-pool implementation). More...
 

Detailed Description

LINQ -like library of higher-order functions for data manipulation.

Typedef Documentation

◆ any_seq_t

template<typename T >
using rangeless::fn::any_seq_t = typedef impl::seq<impl::any_gen<T> >

Definition at line 3444 of file fn.hpp.

Function Documentation

◆ make_typerased()

template<typename Gen , typename T = typename Gen::value_type>
any_seq_t<T> rangeless::fn::make_typerased ( impl::seq< Gen >  seq)
inline

Type-erase a seq.

Wrap the underlying nullary invokable as std::function.

Definition at line 3450 of file fn.hpp.