reverted partition algorithm not needed
Build on RHEL9 / build (push) Successful in 2m28s
Build on RHEL8 / build (push) Successful in 3m3s
Run tests using data on local RHEL8 / build (push) Failing after 3m49s

This commit is contained in:
2026-08-06 09:52:17 +02:00
parent 2497c8cdb0
commit 047a63709b
2 changed files with 1 additions and 132 deletions
-54
View File
@@ -125,58 +125,4 @@ inline double linear_interpolation(const std::pair<double, double> &bin_edge,
bin_values.second * (coord - bin_edge.first) / bin_width;
}
/// @brief XOR operator
inline bool XOR(const bool a, const bool b) { return (a || b) && !(a && b); }
/// @brief range struct
template <typename Iterator> struct range {
/// @brief start of the range
Iterator start{};
/// @brief end of the range
Iterator end{};
};
/**
* @brief partition range of elements into contiguous subranges for which the
* partition criteria is the same.
* @param start pointer to the first element of the range
* @param end pointer to the last element of the range
* @param partition_criteria function that returns true or false for a given
* element
* @return vector of ranges that are contiguous and have the same partition
* criteria
*/
template <typename Iterator>
std::vector<range<Iterator>> partition(
Iterator start, Iterator end,
std::function<bool(const typename std::iterator_traits<Iterator>::value_type
&)> &partition_criteria) {
std::vector<range<Iterator>> partitions;
partitions.reserve(std::distance(start, end));
auto partition_start = start;
auto partition_end = end;
bool chunk_fulfills_criteria = partition_criteria(
*partition_start); // starts with range fulfilling criteria
auto chunk_criteria =
[&partition_criteria, &chunk_fulfills_criteria](
const typename std::iterator_traits<Iterator>::value_type &value) {
return XOR(partition_criteria(value), chunk_fulfills_criteria);
}; // exclusive or
while (partition_start < end) {
partition_end = std::find_if(partition_start, end, chunk_criteria);
partitions.push_back({partition_start, partition_end});
partition_start = partition_end;
chunk_fulfills_criteria =
!chunk_fulfills_criteria; // flip criteria for next chunk
}
return partitions;
}
} // namespace aare