coveo::linq
Implementation of .NET-like LINQ operators in C++
|
Joins and groups elements in two sequences according to their keys. More...
Functions | |
template<typename InnerSeq , typename OuterKeySelector , typename InnerKeySelector , typename ResultSelector > | |
auto | coveo::linq::group_join (InnerSeq &&inner_seq, OuterKeySelector &&outer_key_sel, InnerKeySelector &&inner_key_sel, ResultSelector &&result_sel) -> detail::group_join_impl< InnerSeq, OuterKeySelector, InnerKeySelector, ResultSelector, detail::less<>> |
Joins and groups elements in two sequences according to their keys. More... | |
template<typename InnerSeq , typename OuterKeySelector , typename InnerKeySelector , typename ResultSelector , typename Pred > | |
auto | coveo::linq::group_join (InnerSeq &&inner_seq, OuterKeySelector &&outer_key_sel, InnerKeySelector &&inner_key_sel, ResultSelector &&result_sel, Pred &&pred) -> detail::group_join_impl< InnerSeq, OuterKeySelector, InnerKeySelector, ResultSelector, Pred > |
Joins and groups elements in two sequences according to their keys using predicate. More... | |
The group_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 creates groups of elements from the inner sequence and joins them to elements in the outer sequence with matching keys. Finally, a result selector is used to fold the groups into the final results.
.NET equivalent: GroupJoin
auto coveo::linq::group_join | ( | InnerSeq && | inner_seq, |
OuterKeySelector && | outer_key_sel, | ||
InnerKeySelector && | inner_key_sel, | ||
ResultSelector && | result_sel | ||
) | -> detail::group_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, creates groups of elements from the inner sequence with keys matching that of the elements in the outer sequence. Finally, the provided result selector is used to convert the groups into the final results. The result selector is called with two arguments: an element from the outer sequence and a group of elements 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 to create groups. |
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::group_join | ( | InnerSeq && | inner_seq, |
OuterKeySelector && | outer_key_sel, | ||
InnerKeySelector && | inner_key_sel, | ||
ResultSelector && | result_sel, | ||
Pred && | pred | ||
) | -> detail::group_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, creates groups of elements from the inner sequence with keys matching that of the elements in the outer sequence. Finally, the provided result selector is used to convert the groups into the final results. The result selector is called with two arguments: an element from the outer sequence and a group of elements 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 to create groups. |
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 keys. |
result_sel
.