From 5fa04b30c721a4b518a7d50127e069f540413573 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Gil=20de=20G=C3=B3mez=20P=C3=A9rez?= Date: Mon, 17 Aug 2026 13:42:40 +0300 Subject: [PATCH] Solved: 29 - Iterators --- modules/08_stl_algorithms/src/iterators.cpp | 25 ++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/modules/08_stl_algorithms/src/iterators.cpp b/modules/08_stl_algorithms/src/iterators.cpp index 551a220..54a0111 100644 --- a/modules/08_stl_algorithms/src/iterators.cpp +++ b/modules/08_stl_algorithms/src/iterators.cpp @@ -1,9 +1,28 @@ #include "iterators.hpp" +#include +#include + namespace stl_algorithms { -auto reverse_copy(const std::vector& data) -> std::vector { (void)data; return {}; } -auto countGreaterThan(const std::vector& data, int threshold) -> int { (void)data; (void)threshold; return 0; } -auto everyEven(const std::vector& data) -> bool { (void)data; return false; } +auto reverse_copy(const std::vector& data) -> std::vector { + std::vector result; + for (const auto& element : data | std::views::reverse) { + result.push_back(element); + } + return result; +} + +auto countGreaterThan(const std::vector& data, const int threshold) -> int { + auto count = 0; + for (const auto& element : data) { + if (element > threshold) count++; + } + return count; +} + +auto everyEven(const std::vector& data) -> bool { + return std::ranges::all_of(data, [](const int x) { return x % 2 == 0; }); +} } // namespace stl_algorithms