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