70 lines
1.8 KiB
C++
70 lines
1.8 KiB
C++
#pragma once
|
|
|
|
/* MOUNT CONTROL COMPONENTS LIBRARY */
|
|
|
|
|
|
/* PROHIBITED ZONE CONTAINER UTILITIES */
|
|
|
|
|
|
#include "mcc_generics.h"
|
|
|
|
namespace mcc
|
|
{
|
|
|
|
|
|
template <typename T, traits::mcc_callable_c FuncT>
|
|
void MccPZoneContainerForEach(std::ranges::output_range<T> auto const& input_range, FuncT&& func)
|
|
requires requires(std::remove_cvref_t<FuncT> f, T v) { [](std::remove_cvref_t<FuncT> ff, T vv) { ff(vv); }(f, v); }
|
|
{
|
|
for (auto const& el : input_range) {
|
|
std::forward<FuncT>(func)(el);
|
|
}
|
|
}
|
|
|
|
|
|
template <typename T>
|
|
auto MccPZoneContainerTimeStat(const T& durations,
|
|
traits::mcc_time_duration_c auto* min_time,
|
|
traits::mcc_time_duration_c auto* max_time)
|
|
requires traits::mcc_output_duration_range_c<T>
|
|
{
|
|
if (min_time == nullptr && max_time == nullptr) {
|
|
return;
|
|
}
|
|
|
|
using min_t = std::decay_t<decltype(*min_time)>;
|
|
using max_t = std::decay_t<decltype(*max_time)>;
|
|
|
|
using duration_t = std::ranges::range_value_t<T>;
|
|
duration_t mint = duration_t::max();
|
|
duration_t maxt = duration_t::min();
|
|
|
|
MccPZoneContainerForEach(durations, [&mint, maxt](auto const& d) {
|
|
if (d < mint) {
|
|
mint = d;
|
|
}
|
|
|
|
if (d > maxt) {
|
|
maxt = d;
|
|
}
|
|
});
|
|
|
|
if (min_time != nullptr) {
|
|
*min_time = std::chrono::duration_cast<min_t>(mint);
|
|
}
|
|
|
|
if (max_time != nullptr) {
|
|
*max_time = std::chrono::duration_cast<max_t>(maxt);
|
|
}
|
|
}
|
|
|
|
|
|
template <mcc_celestial_point_c CPT>
|
|
auto MccPZoneContainerIntersectStat(std::ranges::output_range<CPT> auto const& points,
|
|
mcc_celestial_point_c auto* first)
|
|
{
|
|
}
|
|
|
|
|
|
} // namespace mcc
|