coveo::linq
Implementation of .NET-like LINQ operators in C++
|
Joins elements in two sequences according to their keys. More...
Functions | |
template<typename InnerSeq , typename OuterKeySelector , typename InnerKeySelector , typename ResultSelector > | |
auto | coveo::linq::join (InnerSeq &&inner_seq, OuterKeySelector &&outer_key_sel, InnerKeySelector &&inner_key_sel, ResultSelector &&result_sel) -> detail::join_impl< InnerSeq, OuterKeySelector, InnerKeySelector, ResultSelector, detail::less<>> |
Joins elements in two sequences according to their keys. More... | |
template<typename InnerSeq , typename OuterKeySelector , typename InnerKeySelector , typename ResultSelector , typename Pred > | |
auto | coveo::linq::join (InnerSeq &&inner_seq, OuterKeySelector &&outer_key_sel, InnerKeySelector &&inner_key_sel, ResultSelector &&result_sel, Pred &&pred) -> detail::join_impl< InnerSeq, OuterKeySelector, InnerKeySelector, ResultSelector, Pred > |
Joins elements in two sequences according to their keys using predicate. More... | |
The join
operator scans two sequences: an outer sequence and an inner sequence. For each element in the sequences, it extracts a key using some key selectors. Then, it joins elements from the inner sequence to elements in the outer sequence with matching keys. Finally, a result selector is used to fold the elements into the final results. (This operator is similar to a database JOIN.)
.NET equivalent: Join
auto coveo::linq::join | ( | InnerSeq && | inner_seq, |
OuterKeySelector && | outer_key_sel, | ||
InnerKeySelector && | inner_key_sel, | ||
ResultSelector && | result_sel | ||
) | -> detail::join_impl<InnerSeq, OuterKeySelector, InnerKeySelector, ResultSelector, detail::less<>> |
Extracts keys for the elements of an outer sequence (the one on which this operator is applied, e.g. the one passed to coveo::linq::from()
) and the provided inner sequence using the provided key selectors. Next, joins elements from the inner sequence with elements in the outer sequence with matching keys. Finally, the provided result selector is used to convert the elements into the final results. The result selector is called with two arguments: an element from the outer sequence and an element from the inner sequence that share the same key.
In order to match the keys, they are compared using operator<()
.
Use like this:
inner_seq | Inner sequence to scan. |
outer_key_sel | Selector to get keys for elements in the outer sequence. |
inner_key_sel | Selector to get keys for elements in the inner sequence. |
result_sel | Result selector used to produce final results. |
result_sel
. auto coveo::linq::join | ( | InnerSeq && | inner_seq, |
OuterKeySelector && | outer_key_sel, | ||
InnerKeySelector && | inner_key_sel, | ||
ResultSelector && | result_sel, | ||
Pred && | pred | ||
) | -> detail::join_impl<InnerSeq, OuterKeySelector, InnerKeySelector, ResultSelector, Pred> |
Extracts keys for the elements of an outer sequence (the one on which this operator is applied, e.g. the one passed to coveo::linq::from()
) and the provided inner sequence using the provided key selectors. Next, joins elements from the inner sequence with elements in the outer sequence with matching keys. Finally, the provided result selector is used to convert the elements into the final results. The result selector is called with two arguments: an element from the outer sequence and an element from the inner sequence that share the same key.
In order to match the keys, they are compared using the provided predicate. The predicate must provide a strict ordering of the keys, like std::less
.
Use like this:
inner_seq | Inner sequence to scan. |
outer_key_sel | Selector to get keys for elements in the outer sequence. |
inner_key_sel | Selector to get keys for elements in the inner sequence. |
result_sel | Result selector used to produce final results. |
pred | Predicate used to compare the keys. |
result_sel
.