coveo::linq
Implementation of .NET-like LINQ operators in C++
Functions
linq.h File Reference

C++ LINQ operators. More...

Go to the source code of this file.

Functions

template<typename Seq >
auto coveo::linq::from (Seq &&seq) -> decltype(std::forward< Seq >(seq))
 Standard LINQ expression entry point. More...
 
template<typename It >
auto coveo::linq::from_range (It ibeg, It iend) -> decltype(enumerate_range(std::move(ibeg), std::move(iend)))
 LINQ expression entry point from iterators. More...
 
template<typename IntT >
auto coveo::linq::from_int_range (IntT first, std::size_t count) -> coveo::enumerable< const typename std::decay< IntT >::type >
 LINQ expression entry point from range of numbers. More...
 
template<typename T >
auto coveo::linq::from_repeated (const T &value, std::size_t count) -> coveo::enumerable< const typename std::decay< T >::type >
 LINQ expression entry point from a repeated value. More...
 
template<typename Seq , typename Op >
auto coveo::linq::operator| (Seq &&seq, Op &&op) -> decltype(std::forward< Op >(op)(std::forward< Seq >(seq)))
 Applies LINQ operators and allows chaining. More...
 
template<typename F >
auto coveo::linq::aggregate (const F &agg_f) -> detail::aggregate_impl_1< F >
 Aggregates values using an aggregation function. More...
 
template<typename Acc , typename F >
auto coveo::linq::aggregate (const Acc &seed, const F &agg_f) -> detail::aggregate_impl_2< Acc, F >
 Aggregates values using an aggregation function, starting with a seed. More...
 
template<typename Acc , typename F , typename RF >
auto coveo::linq::aggregate (const Acc &seed, const F &agg_f, const RF &result_f) -> detail::aggregate_impl_3< Acc, F, RF >
 Aggregates values using aggregation function, seed and result selector. More...
 
template<typename Pred >
auto coveo::linq::all (const Pred &pred) -> detail::all_impl< Pred >
 Checks elements in a sequence against a predicate. More...
 
template<typename = void>
auto coveo::linq::any () -> detail::any_impl_0<>
 Checks for any element. More...
 
template<typename Pred >
auto coveo::linq::any (const Pred &pred) -> detail::any_impl_1< Pred >
 Checks for any element that satisfy a predicate. More...
 
template<typename F >
auto coveo::linq::average (const F &num_f) -> detail::average_impl< F >
 Computes average using numerical function. More...
 
template<typename U >
auto coveo::linq::cast () -> detail::select_impl< detail::indexless_selector_proxy< detail::cast_selector< U >>>
 Casts sequence elements to another type. More...
 
template<typename Seq2 >
auto coveo::linq::concat (Seq2 &&seq2) -> detail::concat_impl< Seq2 >
 Concatenates two sequences. More...
 
template<typename T >
auto coveo::linq::contains (const T &obj) -> detail::contains_impl_1< T >
 Look for element in a sequence. More...
 
template<typename T , typename Pred >
auto coveo::linq::contains (const T &obj, const Pred &pred) -> detail::contains_impl_2< T, Pred >
 Look for element in a sequence using a predicate. More...
 
template<typename = void>
auto coveo::linq::count () -> detail::count_impl_0<>
 Counts elements in sequence. More...
 
template<typename Pred >
auto coveo::linq::count (const Pred &pred) -> detail::count_impl_1< Pred >
 Counts elements in sequence satisfying a predicate. More...
 
template<typename = void>
auto coveo::linq::default_if_empty () -> detail::default_if_empty_impl_0<>
 Ensures sequence has at least one element. More...
 
template<typename T >
auto coveo::linq::default_if_empty (const T &obj) -> detail::default_if_empty_impl_1< T >
 Ensures sequence has at least one element, specifying said element. More...
 
template<typename = void>
auto coveo::linq::distinct () -> detail::distinct_impl< detail::less<>>
 Filters out duplicate elements in sequence. More...
 
template<typename Pred >
auto coveo::linq::distinct (Pred &&pred) -> detail::distinct_impl< Pred >
 Filters out duplicate elements in sequence using predicate. More...
 
template<typename = void>
auto coveo::linq::element_at (std::size_t n) -> detail::element_at_impl<>
 Returns nth element in sequence. More...
 
template<typename = void>
auto coveo::linq::element_at_or_default (std::size_t n) -> detail::element_at_or_default_impl<>
 Returns nth element in sequence or default value. More...
 
template<typename Seq2 >
auto coveo::linq::except (Seq2 &&seq2) -> detail::except_impl< Seq2, detail::less<>>
 Performs set difference between two sequences. More...
 
template<typename Seq2 , typename Pred >
auto coveo::linq::except (Seq2 &&seq2, Pred &&pred) -> detail::except_impl< Seq2, Pred >
 Performs set difference between two sequences using predicate. More...
 
template<typename = void>
auto coveo::linq::first () -> detail::first_impl_0<>
 Returns first element in sequence. More...
 
template<typename Pred >
auto coveo::linq::first (const Pred &pred) -> detail::first_impl_1< Pred >
 Returns first element in sequence that satisfy predicate. More...
 
template<typename = void>
auto coveo::linq::first_or_default () -> detail::first_or_default_impl_0<>
 Returns first element in sequence, or default value. More...
 
template<typename Pred >
auto coveo::linq::first_or_default (const Pred &pred) -> detail::first_or_default_impl_1< Pred >
 Returns first element in sequence that satisfy predicate, or default value. More...
 
template<typename KeySelector >
auto coveo::linq::group_by (KeySelector &&key_sel) -> detail::group_by_impl< KeySelector, detail::identity<>, detail::pair_of<>, detail::less<>>
 Groups elements in sequence according to their keys. More...
 
template<typename KeySelector , typename Pred >
auto coveo::linq::group_by (KeySelector &&key_sel, Pred &&pred) -> detail::group_by_impl< KeySelector, detail::identity<>, detail::pair_of<>, Pred >
 Groups elements in sequence according to their keys using predicate. More...
 
template<typename KeySelector , typename ValueSelector >
auto coveo::linq::group_values_by (KeySelector &&key_sel, ValueSelector &&value_sel) -> detail::group_by_impl< KeySelector, ValueSelector, detail::pair_of<>, detail::less<>>
 Groups values in sequence according to their keys. More...
 
template<typename KeySelector , typename ValueSelector , typename Pred >
auto coveo::linq::group_values_by (KeySelector &&key_sel, ValueSelector &&value_sel, Pred &&pred) -> detail::group_by_impl< KeySelector, ValueSelector, detail::pair_of<>, Pred >
 Groups values in sequence according to their keys using predicate. More...
 
template<typename KeySelector , typename ResultSelector >
auto coveo::linq::group_by_and_fold (KeySelector &&key_sel, ResultSelector &&result_sel) -> detail::group_by_impl< KeySelector, detail::identity<>, ResultSelector, detail::less<>>
 Groups elements in sequence according to their keys then folds the results. More...
 
template<typename KeySelector , typename ResultSelector , typename Pred >
auto coveo::linq::group_by_and_fold (KeySelector &&key_sel, ResultSelector &&result_sel, Pred &&pred) -> detail::group_by_impl< KeySelector, detail::identity<>, ResultSelector, Pred >
 Groups elements in sequence according to their keys using predicate, then folds the results. More...
 
template<typename KeySelector , typename ValueSelector , typename ResultSelector >
auto coveo::linq::group_values_by_and_fold (KeySelector &&key_sel, ValueSelector &&value_sel, ResultSelector &&result_sel) -> detail::group_by_impl< KeySelector, ValueSelector, ResultSelector, detail::less<>>
 Groups values in sequence according to their keys then folds the results. More...
 
template<typename KeySelector , typename ValueSelector , typename ResultSelector , typename Pred >
auto coveo::linq::group_values_by_and_fold (KeySelector &&key_sel, ValueSelector &&value_sel, ResultSelector &&result_sel, Pred &&pred) -> detail::group_by_impl< KeySelector, ValueSelector, ResultSelector, Pred >
 Groups values in sequence according to their keys using predicate, then folds the results. More...
 
template<typename InnerSeq , typename OuterKeySelector , typename InnerKeySelector , typename ResultSelector >
auto coveo::linq::group_join (InnerSeq &&inner_seq, OuterKeySelector &&outer_key_sel, InnerKeySelector &&inner_key_sel, ResultSelector &&result_sel) -> detail::group_join_impl< InnerSeq, OuterKeySelector, InnerKeySelector, ResultSelector, detail::less<>>
 Joins and groups elements in two sequences according to their keys. More...
 
template<typename InnerSeq , typename OuterKeySelector , typename InnerKeySelector , typename ResultSelector , typename Pred >
auto coveo::linq::group_join (InnerSeq &&inner_seq, OuterKeySelector &&outer_key_sel, InnerKeySelector &&inner_key_sel, ResultSelector &&result_sel, Pred &&pred) -> detail::group_join_impl< InnerSeq, OuterKeySelector, InnerKeySelector, ResultSelector, Pred >
 Joins and groups elements in two sequences according to their keys using predicate. More...
 
template<typename Seq2 >
auto coveo::linq::intersect (Seq2 &&seq2) -> detail::intersect_impl< Seq2, detail::less<>>
 Performs set intersection of two sequences. More...
 
template<typename Seq2 , typename Pred >
auto coveo::linq::intersect (Seq2 &&seq2, Pred &&pred) -> detail::intersect_impl< Seq2, Pred >
 Performs set intersection of two sequences using predicate. More...
 
template<typename InnerSeq , typename OuterKeySelector , typename InnerKeySelector , typename ResultSelector >
auto coveo::linq::join (InnerSeq &&inner_seq, OuterKeySelector &&outer_key_sel, InnerKeySelector &&inner_key_sel, ResultSelector &&result_sel) -> detail::join_impl< InnerSeq, OuterKeySelector, InnerKeySelector, ResultSelector, detail::less<>>
 Joins elements in two sequences according to their keys. More...
 
template<typename InnerSeq , typename OuterKeySelector , typename InnerKeySelector , typename ResultSelector , typename Pred >
auto coveo::linq::join (InnerSeq &&inner_seq, OuterKeySelector &&outer_key_sel, InnerKeySelector &&inner_key_sel, ResultSelector &&result_sel, Pred &&pred) -> detail::join_impl< InnerSeq, OuterKeySelector, InnerKeySelector, ResultSelector, Pred >
 Joins elements in two sequences according to their keys using predicate. More...
 
template<typename = void>
auto coveo::linq::last () -> detail::last_impl_0<>
 Returns last element in sequence. More...
 
template<typename Pred >
auto coveo::linq::last (const Pred &pred) -> detail::last_impl_1< Pred >
 Returns last element in sequence that satisfy predicate. More...
 
template<typename = void>
auto coveo::linq::last_or_default () -> detail::last_or_default_impl_0<>
 Returns last element in sequence, or default value. More...
 
template<typename Pred >
auto coveo::linq::last_or_default (const Pred &pred) -> detail::last_or_default_impl_1< Pred >
 Returns last element in sequence that satisfy predicate, or default value. More...
 
template<typename = void>
auto coveo::linq::max () -> detail::max_impl_0<>
 Returns maximum element in sequence. More...
 
template<typename Selector >
auto coveo::linq::max (const Selector &sel) -> detail::max_impl_1< Selector >
 Returns maximum projected value in sequence. More...
 
template<typename = void>
auto coveo::linq::min () -> detail::min_impl_0<>
 Returns minimum element in sequence. More...
 
template<typename Selector >
auto coveo::linq::min (const Selector &sel) -> detail::min_impl_1< Selector >
 Returns minimum projected value in sequence. More...
 
template<typename Pred >
auto coveo::linq::none (const Pred &pred) -> detail::none_impl< Pred >
 Checks elements in a sequence against a predicate. More...
 
template<typename KeySelector >
auto coveo::linq::order_by (KeySelector &&key_sel) -> detail::order_by_impl< detail::order_by_comparator< KeySelector, detail::less<>, false >>
 Orders elements in sequence by ascending key. More...
 
template<typename KeySelector , typename Pred >
auto coveo::linq::order_by (KeySelector &&key_sel, Pred &&pred) -> detail::order_by_impl< detail::order_by_comparator< KeySelector, Pred, false >>
 Orders elements in sequence by ascending key using predicate. More...
 
template<typename KeySelector >
auto coveo::linq::order_by_descending (KeySelector &&key_sel) -> detail::order_by_impl< detail::order_by_comparator< KeySelector, detail::less<>, true >>
 Orders elements in sequence by descending key. More...
 
template<typename KeySelector , typename Pred >
auto coveo::linq::order_by_descending (KeySelector &&key_sel, Pred &&pred) -> detail::order_by_impl< detail::order_by_comparator< KeySelector, Pred, true >>
 Orders elements in sequence by descending key using predicate. More...
 
template<typename KeySelector >
auto coveo::linq::then_by (KeySelector &&key_sel) -> decltype(order_by(std::forward< KeySelector >(key_sel)))
 Further orders elements in sequence by ascending key. More...
 
template<typename KeySelector , typename Pred >
auto coveo::linq::then_by (KeySelector &&key_sel, Pred &&pred) -> decltype(order_by(std::forward< KeySelector >(key_sel), std::forward< Pred >(pred)))
 Further orders elements in sequence by ascending key using predicate. More...
 
template<typename KeySelector >
auto coveo::linq::then_by_descending (KeySelector &&key_sel) -> decltype(order_by_descending(std::forward< KeySelector >(key_sel)))
 Further orders elements in sequence by descending key. More...
 
template<typename KeySelector , typename Pred >
auto coveo::linq::then_by_descending (KeySelector &&key_sel, Pred &&pred) -> decltype(order_by_descending(std::forward< KeySelector >(key_sel), std::forward< Pred >(pred)))
 Further orders elements in sequence by descending key using predicate. More...
 
template<typename = void>
auto coveo::linq::reverse () -> detail::reverse_impl<>
 Reverses elements in sequence. More...
 
template<typename Selector >
auto coveo::linq::select (Selector &&sel) -> detail::select_impl< detail::indexless_selector_proxy< Selector >>
 Projects elements in sequence into another form. More...
 
template<typename Selector >
auto coveo::linq::select_with_index (Selector &&sel) -> detail::select_impl< Selector >
 Projects elements in sequence into another form using element index. More...
 
template<typename Selector >
auto coveo::linq::select_many (Selector &&sel) -> detail::select_many_impl< detail::indexless_selector_proxy< Selector >>
 Projects elements in sequence into many values and flattens them. More...
 
template<typename Selector >
auto coveo::linq::select_many_with_index (Selector &&sel) -> detail::select_many_impl< Selector >
 Projects elements in sequence into many values using element index and flattens them. More...
 
template<typename Seq2 >
auto coveo::linq::sequence_equal (const Seq2 &seq2) -> detail::sequence_equal_impl_1< Seq2 >
 Compares elements in two sequences. More...
 
template<typename Seq2 , typename Pred >
auto coveo::linq::sequence_equal (const Seq2 &seq2, const Pred &pred) -> detail::sequence_equal_impl_2< Seq2, Pred >
 Compares elements in two sequences using predicate. More...
 
template<typename = void>
auto coveo::linq::single () -> detail::single_impl_0<>
 Returns only element in sequence. More...
 
template<typename Pred >
auto coveo::linq::single (const Pred &pred) -> detail::single_impl_1< Pred >
 Returns only element in sequence satisfying predicate. More...
 
template<typename = void>
auto coveo::linq::single_or_default () -> detail::single_or_default_impl_0<>
 Returns only element in sequence, or default value. More...
 
template<typename Pred >
auto coveo::linq::single_or_default (const Pred &pred) -> detail::single_or_default_impl_1< Pred >
 Returns only element in sequence satisfying predicate, or default value. More...
 
template<typename = void>
auto coveo::linq::skip (std::size_t n) -> detail::skip_impl< detail::skip_n_pred<>>
 Skips the first N elements in sequence. More...
 
template<typename Pred >
auto coveo::linq::skip_while (Pred &&pred) -> detail::skip_impl< detail::indexless_selector_proxy< Pred >>
 Skips the first elements in sequence satisfying predicate. More...
 
template<typename Pred >
auto coveo::linq::skip_while_with_index (Pred &&pred) -> detail::skip_impl< Pred >
 Skips the first elements in sequence satisfying predicate using element index. More...
 
template<typename F >
auto coveo::linq::sum (const F &num_f) -> detail::sum_impl< F >
 Computes sum using numerical function. More...
 
template<typename = void>
auto coveo::linq::take (std::size_t n) -> detail::take_impl< detail::skip_n_pred<>>
 Keeps the first N elements in sequence. More...
 
template<typename Pred >
auto coveo::linq::take_while (Pred &&pred) -> detail::take_impl< detail::indexless_selector_proxy< Pred >>
 Keeps the first elements in sequence satisfying predicate. More...
 
template<typename Pred >
auto coveo::linq::take_while_with_index (Pred &&pred) -> detail::take_impl< Pred >
 Keeps the first elements in sequence satisfying predicate using element index. More...
 
template<typename Container >
auto coveo::linq::to () -> detail::to_impl< Container >
 Converts sequence into another container. More...
 
template<typename = void>
auto coveo::linq::to_vector () -> detail::to_vector_impl<>
 Converts sequence into std::vector. More...
 
template<typename Container , typename KeySelector >
auto coveo::linq::to_associative (const KeySelector &key_sel) -> detail::to_associative_impl_1< Container, KeySelector >
 Converts sequence into associative container using key selector. More...
 
template<typename Container , typename KeySelector , typename ElementSelector >
auto coveo::linq::to_associative (const KeySelector &key_sel, const ElementSelector &elem_sel) -> detail::to_associative_impl_2< Container, KeySelector, ElementSelector >
 Converts sequence into associative container using key and element selector. More...
 
template<typename KeySelector >
auto coveo::linq::to_map (const KeySelector &key_sel) -> detail::to_map_impl_1< KeySelector >
 Converts sequence into std::map using key selector. More...
 
template<typename KeySelector , typename ElementSelector >
auto coveo::linq::to_map (const KeySelector &key_sel, const ElementSelector &elem_sel) -> detail::to_map_impl_2< KeySelector, ElementSelector >
 Converts sequence into std::map using key and element selector. More...
 
template<typename Seq2 >
auto coveo::linq::union_with (Seq2 &&seq2) -> detail::union_impl< Seq2, detail::less<>>
 Performs set union of two sequences. More...
 
template<typename Seq2 , typename Pred >
auto coveo::linq::union_with (Seq2 &&seq2, Pred &&pred) -> detail::union_impl< Seq2, Pred >
 Performs set union of two sequences using predicate. More...
 
template<typename Pred >
auto coveo::linq::where (Pred &&pred) -> detail::where_impl< detail::indexless_selector_proxy< Pred >>
 Filters sequence elements using predicate. More...
 
template<typename Pred >
auto coveo::linq::where_with_index (Pred &&pred) -> detail::where_impl< Pred >
 Filters sequence elements using predicate and element index. More...
 
template<typename Seq2 , typename ResultSelector >
auto coveo::linq::zip (Seq2 &&seq2, ResultSelector &&result_sel) -> detail::zip_impl< Seq2, ResultSelector >
 Zips two sequences. More...
 

Detailed Description

This file contains the definition of all LINQ operators, as well as the entry points (e.g., coveo::linq::from(), etc.) and the chaining operator (e.g. coveo::linq::operator|()). This is the only file that needs to be included to use the library.