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

Returns minimum element in a sequence. More...

Functions

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

Detailed Description

The min operator returns the minimum element in a sequence. If the sequence does not have elements, an exception is thrown.

This is a terminal operator.

.NET equivalent: Min

Function Documentation

◆ min() [1/2]

template<typename = void>
auto coveo::linq::min ( ) -> detail::min_impl_0<>

Returns the minimum element in a sequence. If the sequence does not have elements, coveo::linq::empty_sequence is thrown.

Use like this:

const std::vector<int> YES = { 42, 23, 66, 11, 7 };
const std::vector<int> NAY;
using namespace coveo::linq;
auto min1 = from(YES)
| min();
// min1 == 7
// This throws an exception:
// auto min2 = from(NAY)
// | min();
Returns
(Once applied) Minimum element in sequence.
Exceptions
coveo::linq::empty_sequenceThe sequence does not have elements.

◆ min() [2/2]

template<typename Selector >
auto coveo::linq::min ( const Selector &  sel) -> detail::min_impl_1<Selector>

Returns the minimum value in a sequence by projecting each element to a different value using the provided selector. If the sequence does not have elements, coveo::linq::empty_sequence is thrown.

Use like this:

const std::vector<int> YES = { 42, 23, 66, 11, 7 };
const std::vector<int> NAY;
using namespace coveo::linq;
auto min1 = from(YES)
| min([](int i) { return -i; });
// min1 == -66
// This throws an exception:
// auto min2 = from(NAY)
// | min([](int i) { return -i; });
Parameters
selSelector called to project each element into a different value.
Returns
(Once applied) Minimum projected value in sequence.
Exceptions
coveo::linq::empty_sequenceThe sequence does not have elements.