|
coveo::linq
Implementation of .NET-like LINQ operators in C++
|
Aggregates values in a sequence to produce a single value. More...
Functions | |
| 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... | |
The aggregate operator, as its name implies, can be used to aggregate all values in a sequence into a single value. To achieve this, it needs an aggregation function that will be called repeatedly to add each element in the sequence to the aggregate.
This is a terminal operator.
.NET equivalent: Aggregate
| auto coveo::linq::aggregate | ( | const F & | agg_f | ) | -> detail::aggregate_impl_1<F> |
Aggregates all elements in a sequence by repeatedly calling an aggregation function. The function receives two parameters: the current aggregate value, and the sequence element to add. The function must then add the element to the aggregate and return a new aggregate value. On the first call, the aggregate value is the first sequence element.
Does not work on empty sequences.
Use like this:
| agg_f | Aggregation function. |
| coveo::linq::empty_sequence | The sequence contains no elements. |
| auto coveo::linq::aggregate | ( | const Acc & | seed, |
| const F & | agg_f | ||
| ) | -> detail::aggregate_impl_2<Acc, F> |
Aggregates all elements in a sequence by repeatedly calling an aggregation function. The function receives two parameters: the current aggregate value, and the sequence element to add. The function must then add the element to the aggregate and return a new aggregate value. On the first call, the aggregate value is equal to the provided seed.
Use like this:
| seed | Initial aggregate value. |
| agg_f | Aggregation function. |
| auto coveo::linq::aggregate | ( | const Acc & | seed, |
| const F & | agg_f, | ||
| const RF & | result_f | ||
| ) | -> detail::aggregate_impl_3<Acc, F, RF> |
Aggregates all elements in a sequence by repeatedly calling an aggregation function. The function receives two parameters: the current aggregate value, and the sequence element to add. The function must then add the element to the aggregate and return a new aggregate value. On the first call, the aggregate value is equal to the provided seed. Once the final aggregate value is computed, it is passed to a result selector to produce a final value to return.
Use like this:
| seed | Initial aggregate value. |
| agg_f | Aggregation function. |
| result_f | Function used to produce final result from aggregate. |
result_f.
1.8.15