18#ifndef MOTIV_UTILS_HPP
19#define MOTIV_UTILS_HPP
24#include "src/models/communication/CommunicationKind.hpp"
25#include "src/models/Range.hpp"
34void resetLayout(QLayout *apLayout);
36std::string communicationKindName(CommunicationKind kind);
38std::string collectiveCommunicationOperationName(otf2::collective_type type);
40template<
typename T,
typename K,
typename C = std::less<K>>
41std::map<K, Range<T>, C> groupBy(
Range<T> range, std::function<K(
const T)> keySelector, std::function<
bool(
const T,
const T)> compare) {
43 std::map<K, Range<T>, C> group;
51 std::sort(range.
begin(), range.
end(), compare);
53 auto start = range.
begin();
54 auto it = range.
begin() + 1;
55 while(it != range.
end()) {
56 auto key = keySelector(*it);
57 auto startKey = keySelector(*start);
58 if((keyComparator(key, startKey) || keyComparator(startKey, key))) {
59 auto r = std::vector<T>(start, it);
66 auto startKey = keySelector(*start);
67 auto r = std::vector<T>(start, it);
73template<
typename T,
typename K,
typename C = std::less<K>>
74std::map<K, Range<T>, C> groupBy(
Range<T> range, std::function<K(
const T)> keySelector) {
75 return groupBy(range, keySelector, [](
const T lhs,
const T rhs) {
return lhs < rhs;});
A custom range implementation around std::vector<T>s.