Solved: 53 - Pipeline Ranges

This commit is contained in:
2026-08-24 19:50:20 +03:00
parent 64b29cfebe
commit 1dcb4c85c5
+14 -8
View File
@@ -1,17 +1,23 @@
#include "pipeline_ranges.hpp" #include "pipeline_ranges.hpp"
#include <map>
#include <ranges>
namespace cpp26 { namespace cpp26 {
auto top_values_by_category(const std::vector<Record>& records, int min_value) auto top_values_by_category(const std::vector<Record>& records, const int min_value) -> std::vector<Record> {
-> std::vector<Record> { return records
(void)records; (void)min_value; | std::views::filter([min_value](const auto& record) { return record.value > min_value; })
return {}; | std::ranges::to<std::vector<Record>>();
} }
auto total_by_category(const std::vector<Record>& records) auto total_by_category(const std::vector<Record>& records) -> std::vector<std::pair<std::string, int>> {
-> std::vector<std::pair<std::string, int>> { std::map<std::string, int> grouped;
(void)records; for (const auto&[category, value] : records) {
return {}; grouped[category] += value;
}
return grouped
| std::ranges::to<std::vector<std::pair<std::string, int>>>();
} }
} // namespace cpp26 } // namespace cpp26