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

Performs a set difference between two sequences. More...

Functions

template<typename Seq2 >
auto coveo::linq::except (Seq2 &&seq2) -> detail::except_impl< Seq2, detail::less<>>
 Performs set difference between two sequences. More...
 
template<typename Seq2 , typename Pred >
auto coveo::linq::except (Seq2 &&seq2, Pred &&pred) -> detail::except_impl< Seq2, Pred >
 Performs set difference between two sequences using predicate. More...
 

Detailed Description

The except operator returns all elements in the first sequence that are not also found in the second sequence (essentially a set difference). The elements are returned in the order that they appear in the first sequence.

.NET equivalent: Except

Function Documentation

◆ except() [1/2]

template<typename Seq2 >
auto coveo::linq::except ( Seq2 &&  seq2) -> detail::except_impl<Seq2, detail::less<>>

Returns a sequence containing all elements from the first source sequence that are not also in the second source sequence (essentially a set difference). Elements are returned in the order that they appear in the first sequence.

To filter out elements, elements are sorted using operator<().

Use like this:

const int YES[] = { 42, 23, 66, 11, 7, 67 };
const int NO[] = { 10, 7, 60, 42, 43, 50 };
using namespace coveo::linq;
auto seq = from(YES)
| except(NO);
// seq = { 23, 66, 11, 67 }
Parameters
seq2Second source sequence, containing the elements to filter out.
Returns
(Once applied) Sequence containing elements from first source sequence that are not in seq2.

◆ except() [2/2]

template<typename Seq2 , typename Pred >
auto coveo::linq::except ( Seq2 &&  seq2,
Pred &&  pred 
) -> detail::except_impl<Seq2, Pred>

Returns a sequence containing all elements from the first source sequence that are not also in the second source sequence (essentially a set difference). Elements are returned in the order that they appear in the first sequence.

To filter out elements, the provided predicate is used to sort the elements. The predicate must provide a strict ordering of the elements, like std::less.

Use like this:

const int YES[] = { 42, 23, 66, 11, 7, 67 };
const int NO[] = { 10, 7, 60, 42, 43, 50 };
using namespace coveo::linq;
auto seq = from(YES)
| except(NO, [](int i, int j) { return i > j; });
// seq = { 23, 66, 11, 67 }
Parameters
seq2Second source sequence, containing the elements to filter out.
predPredicate used to order elements to filter out.
Returns
(Once applied) Sequence containing elements from first source sequence that are not in seq2.