coveo::linq
Implementation of .NET-like LINQ operators in C++
|
Orders elements in a sequence. More...
Functions | |
template<typename KeySelector > | |
auto | coveo::linq::order_by (KeySelector &&key_sel) -> detail::order_by_impl< detail::order_by_comparator< KeySelector, detail::less<>, false >> |
Orders elements in sequence by ascending key. More... | |
template<typename KeySelector , typename Pred > | |
auto | coveo::linq::order_by (KeySelector &&key_sel, Pred &&pred) -> detail::order_by_impl< detail::order_by_comparator< KeySelector, Pred, false >> |
Orders elements in sequence by ascending key using predicate. More... | |
template<typename KeySelector > | |
auto | coveo::linq::order_by_descending (KeySelector &&key_sel) -> detail::order_by_impl< detail::order_by_comparator< KeySelector, detail::less<>, true >> |
Orders elements in sequence by descending key. More... | |
template<typename KeySelector , typename Pred > | |
auto | coveo::linq::order_by_descending (KeySelector &&key_sel, Pred &&pred) -> detail::order_by_impl< detail::order_by_comparator< KeySelector, Pred, true >> |
Orders elements in sequence by descending key using predicate. More... | |
template<typename KeySelector > | |
auto | coveo::linq::then_by (KeySelector &&key_sel) -> decltype(order_by(std::forward< KeySelector >(key_sel))) |
Further orders elements in sequence by ascending key. More... | |
template<typename KeySelector , typename Pred > | |
auto | coveo::linq::then_by (KeySelector &&key_sel, Pred &&pred) -> decltype(order_by(std::forward< KeySelector >(key_sel), std::forward< Pred >(pred))) |
Further orders elements in sequence by ascending key using predicate. More... | |
template<typename KeySelector > | |
auto | coveo::linq::then_by_descending (KeySelector &&key_sel) -> decltype(order_by_descending(std::forward< KeySelector >(key_sel))) |
Further orders elements in sequence by descending key. More... | |
template<typename KeySelector , typename Pred > | |
auto | coveo::linq::then_by_descending (KeySelector &&key_sel, Pred &&pred) -> decltype(order_by_descending(std::forward< KeySelector >(key_sel), std::forward< Pred >(pred))) |
Further orders elements in sequence by descending key using predicate. More... | |
The order_by
operator (and its siblings) extract keys from each element in a sequence, then orders those elements according to those keys. Depending on the operator used, the ordering will be ascending or descending. If multiple operators are chained (using coveo::linq::then_by()
), elements will be ordered according to the first key extracted and elements with equivalent keys will be further ordered by the other keys.
.NET equivalent: OrderBy / OrderByDescending / ThenBy / ThenByDescending
auto coveo::linq::order_by | ( | KeySelector && | key_sel | ) | -> detail::order_by_impl<detail::order_by_comparator<KeySelector, detail::less<>, false>> |
For each element in the input sequence, extracts a key using the provided key selector. Then, returns a sequence containing the same elements, ordered according to the keys in ascending order.
Keys are compared using operator<()
.
Use like this:
key_sel | Key selector, used to extract a key for a sequence element. |
auto coveo::linq::order_by | ( | KeySelector && | key_sel, |
Pred && | pred | ||
) | -> detail::order_by_impl<detail::order_by_comparator<KeySelector, Pred, false>> |
For each element in the input sequence, extracts a key using the provided key selector. Then, returns a sequence containing the same elements, ordered according to the keys in ascending order.
Keys are compared using the provided predicate. The predicate must provide a strict ordering of the keys, like std::less
.
Use like this:
key_sel | Key selector, used to extract a key for a sequence element. |
pred | Predicate used to compare the keys. |
auto coveo::linq::order_by_descending | ( | KeySelector && | key_sel | ) | -> detail::order_by_impl<detail::order_by_comparator<KeySelector, detail::less<>, true>> |
For each element in the input sequence, extracts a key using the provided key selector. Then, returns a sequence containing the same elements, ordered according to the keys in descending order.
Keys are compared using operator<()
, but the result is reversed to produce descending order.
Use like this:
key_sel | Key selector, used to extract a key for a sequence element. |
auto coveo::linq::order_by_descending | ( | KeySelector && | key_sel, |
Pred && | pred | ||
) | -> detail::order_by_impl<detail::order_by_comparator<KeySelector, Pred, true>> |
For each element in the input sequence, extracts a key using the provided key selector. Then, returns a sequence containing the same elements, ordered according to the keys in descending order.
Keys are compared using the provided predicate, but the result is reversed to produce descending order. The predicate must provide a strict ordering of the keys, like std::less
.
Use like this:
key_sel | Key selector, used to extract a key for a sequence element. |
pred | Predicate used to compare the keys. |
auto coveo::linq::then_by | ( | KeySelector && | key_sel | ) | -> decltype(order_by(std::forward<KeySelector>(key_sel))) |
Further orders a sequence previously ordered via coveo::linq::order_by()
or similar operator. Elements that were previously considered equivalent will be further ordered by ascending order of keys as extracted by the provided key selector.
Keys are compared using operator<()
.
Use like this:
key_sel | Key selector, used to extract a key for a sequence element. |
auto coveo::linq::then_by | ( | KeySelector && | key_sel, |
Pred && | pred | ||
) | -> decltype(order_by(std::forward<KeySelector>(key_sel), std::forward<Pred>(pred))) |
Further orders a sequence previously ordered via coveo::linq::order_by()
or similar operator. Elements that were previously considered equivalent will be further ordered by ascending order of keys as extracted by the provided key selector.
Keys are compared using the provided predicate. The predicate must provide a strict ordering of the keys, like std::less
.
Use like this:
key_sel | Key selector, used to extract a key for a sequence element. |
pred | Predicate used to compare the keys. |
auto coveo::linq::then_by_descending | ( | KeySelector && | key_sel | ) | -> decltype(order_by_descending(std::forward<KeySelector>(key_sel))) |
Further orders a sequence previously ordered via coveo::linq::order_by()
or similar operator. Elements that were previously considered equivalent will be further ordered by descending order of keys as extracted by the provided key selector.
Keys are compared using operator<()
, but the result is reversed to produce descending order.
Use like this:
key_sel | Key selector, used to extract a key for a sequence element. |
auto coveo::linq::then_by_descending | ( | KeySelector && | key_sel, |
Pred && | pred | ||
) | -> decltype(order_by_descending(std::forward<KeySelector>(key_sel), std::forward<Pred>(pred))) |
Further orders a sequence previously ordered via coveo::linq::order_by()
or similar operator. Elements that were previously considered equivalent will be further ordered by descending order of keys as extracted by the provided key selector.
Keys are compared using the provided predicate, but the result is reversed to produce descending order. The predicate must provide a strict ordering of the keys, like std::less
.
Use like this:
key_sel | Key selector, used to extract a key for a sequence element. |
pred | Predicate used to compare the keys. |