coveo::linq
Implementation of .NET-like LINQ operators in C++
Functions
skip / skip_while / skip_while_with_index

Skips the first elements in a sequence. More...

Functions

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...
 

Detailed Description

The skip operator (and its siblings) skip the first elements in a sequence, either by skipping a certain number or using a predicate.

.NET equivalent: Skip / SkipWhile

Function Documentation

◆ skip()

template<typename = void>
auto coveo::linq::skip ( std::size_t  n) -> detail::skip_impl<detail::skip_n_pred<>>

Given a source sequence, returns a new sequence that skips the first n elements of the source sequence. If the source sequence contains less than n elements, returns an empty sequence.

Use like this:

const int NUMS = { 42, 23, 66, 11, 7 };
using namespace coveo::linq;
auto seq = from(NUMS)
| skip(3);
// seq == { 11, 7 }
Parameters
nNumber of elements to skip.
Returns
(Once applied) New sequence skipping the first n elements of source sequence.

◆ skip_while()

template<typename Pred >
auto coveo::linq::skip_while ( Pred &&  pred) -> detail::skip_impl<detail::indexless_selector_proxy<Pred>>

Given a source sequence, returns a new sequence that skips the first elements of the source sequence that satisfy the provided predicate. If the source sequence contains only elements that satisfy the predicate, returns an empty sequence.

Use like this:

const int NUMS = { 42, 23, 66, 11, 7 };
using namespace coveo::linq;
auto seq = from(NUMS)
| skip_while([](int i) { return i < 60; });
// seq == { 66, 11, 7 }
Parameters
predPredicate used to skip elements.
Returns
(Once applied) New sequence skipping the first elements of source sequence satisfying pred.

◆ skip_while_with_index()

template<typename Pred >
auto coveo::linq::skip_while_with_index ( Pred &&  pred) -> detail::skip_impl<Pred>

Given a source sequence, returns a new sequence that skips the first elements of the source sequence that satisfy the provided predicate. If the source sequence contains only elements 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:

const int NUMS = { 42, 23, 66, 11, 7 };
using namespace coveo::linq;
auto seq = from(NUMS)
| skip_while_with_index([](int i, std::size_t idx) { return i < 90 && idx < 3; });
// seq == { 11, 7 }
Parameters
predPredicate used to skip elements.
Returns
(Once applied) New sequence skipping the first elements of source sequence satisfying pred.