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

Counts elements in a sequence. More...

Functions

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

Detailed Description

The count operator computes the number of elements in a sequence, or the number of elements satisfying a given predicate.

This is a terminal operator.

.NET equivalent: Count

Function Documentation

◆ count() [1/2]

template<typename = void>
auto coveo::linq::count ( ) -> detail::count_impl_0<>

Computes the number of elements in a sequence.

Use like this:

const int NUMS[] = { 42, 23, 66 };
using namespace coveo::linq;
auto num = from(NUMS)
| count();
// num == 3
Returns
(Once applied) Number of elements in sequence.

◆ count() [2/2]

template<typename Pred >
auto coveo::linq::count ( const Pred &  pred) -> detail::count_impl_1<Pred>

Computes the number of elements in a sequence that satisfy the given predicate.

Use like this:

const int NUMS[] = { 42, 23, 66 };
using namespace coveo::linq;
auto num = from(NUMS)
| count([](int i) { return i % 2 == 0; });
// num == 2
Parameters
predPredicate to satisfy.
Returns
(Once applied) Number of elements in sequence for which pred has returned true.