Solved: 29 - Iterators

This commit is contained in:
David Gil de Gómez Pérez
2026-08-17 13:42:40 +03:00
parent 7a8e430982
commit 5fa04b30c7
+22 -3
View File
@@ -1,9 +1,28 @@
#include "iterators.hpp"
#include <algorithm>
#include <ranges>
namespace stl_algorithms {
auto reverse_copy(const std::vector<int>& data) -> std::vector<int> { (void)data; return {}; }
auto countGreaterThan(const std::vector<int>& data, int threshold) -> int { (void)data; (void)threshold; return 0; }
auto everyEven(const std::vector<int>& data) -> bool { (void)data; return false; }
auto reverse_copy(const std::vector<int>& data) -> std::vector<int> {
std::vector<int> result;
for (const auto& element : data | std::views::reverse) {
result.push_back(element);
}
return result;
}
auto countGreaterThan(const std::vector<int>& data, const int threshold) -> int {
auto count = 0;
for (const auto& element : data) {
if (element > threshold) count++;
}
return count;
}
auto everyEven(const std::vector<int>& data) -> bool {
return std::ranges::all_of(data, [](const int x) { return x % 2 == 0; });
}
} // namespace stl_algorithms