coveo::linq
Implementation of .NET-like LINQ operators in C++
|
Keeps only the first elements in a sequence. More...
Functions | |
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... | |
The take
operator (and its siblings) keep only the first elements in a sequence, either by taking a certain number or using a predicate.
.NET equivalent: Take / TakeWhile
auto coveo::linq::take | ( | std::size_t | n | ) | -> detail::take_impl<detail::skip_n_pred<>> |
Given a source sequence, returns a new sequence that contains only the first n
elements of the source sequence. If the source sequence contains less than n
elements, returns as many elements as possible.
Use like this:
n | Number of elements to take. |
n
elements of source sequence. auto coveo::linq::take_while | ( | Pred && | pred | ) | -> detail::take_impl<detail::indexless_selector_proxy<Pred>> |
Given a source sequence, returns a new sequence that contains only the first elements of the source sequence that satisfy the provided predicate. If the source sequence contains no element that satisfy the predicate, returns an empty sequence.
Use like this:
pred | Predicate used to take elements. |
pred
. auto coveo::linq::take_while_with_index | ( | Pred && | pred | ) | -> detail::take_impl<Pred> |
Given a source sequence, returns a new sequence that contains only the first elements of the source sequence that satisfy the provided predicate. If the source sequence contains no element that satisfy the predicate, returns an empty sequence.
The predicate is called with two parameters every time: an element from the source sequence, and its position in the sequence.
Use like this:
pred | Predicate used to take elements. |
pred
.