14 #ifndef LARDATA_UTILITIES_FOR_EACH_ASSOCIATED_GROUP_H 15 #define LARDATA_UTILITIES_FOR_EACH_ASSOCIATED_GROUP_H 24 #include "range/v3/algorithm/for_each.hpp" 25 #include "range/v3/view/all.hpp" 26 #include "range/v3/view/group_by.hpp" 27 #include "range/v3/view/map.hpp" 28 #include "range/v3/view/transform.hpp" 45 template <
class A,
class F>
95 return assns | ranges::views::all |
96 ranges::views::chunk_by([](
auto a1,
auto a2) {
return a1.first ==
a2.first; }) |
97 ranges::views::transform(
152 return assns | ranges::views::all |
153 ranges::views::chunk_by([](
auto a1,
auto a2) {
return a1.first ==
a2.first; }) |
154 ranges::views::transform([](
auto pairs) {
155 return std::make_pair(pairs.front().first,
172 template <
typename Groups>
173 auto groupByIndex(Groups&& groups, std::size_t index) -> decltype(
auto)
175 return *(std::next(groups.begin(), index));
180 #endif // LARDATA_UTILITIES_FOR_EACH_ASSOCIATED_GROUP_H auto associated_groups_with_left(A const &assns)
Helper functions to access associations in order, also with key.
Namespace for general, non-LArSoft-specific utilities.
void for_each_associated_group(A const &assns, F &func)
Helper functions to access associations in order.
Utility function to enable range-for on different type iterators.
auto associated_groups(A const &assns)
Helper functions to access associations in order.
constexpr RangeForWrapperTag range_for
decltype(auto) values(Coll &&coll)
Range-for loop helper iterating across the values of the specified collection.
auto groupByIndex(Groups &&groups, std::size_t index) -> decltype(auto)
Returns the group within groups with the specified index.
void for_each_group(art::Assns< A, B, D > const &assns, F func)
Helper functions to access associations in order.