Solved: 29 - Iterators
This commit is contained in:
@@ -1,9 +1,28 @@
|
|||||||
#include "iterators.hpp"
|
#include "iterators.hpp"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
#include <ranges>
|
||||||
|
|
||||||
namespace stl_algorithms {
|
namespace stl_algorithms {
|
||||||
|
|
||||||
auto reverse_copy(const std::vector<int>& data) -> std::vector<int> { (void)data; return {}; }
|
auto reverse_copy(const std::vector<int>& data) -> std::vector<int> {
|
||||||
auto countGreaterThan(const std::vector<int>& data, int threshold) -> int { (void)data; (void)threshold; return 0; }
|
std::vector<int> result;
|
||||||
auto everyEven(const std::vector<int>& data) -> bool { (void)data; return false; }
|
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
|
} // namespace stl_algorithms
|
||||||
|
|||||||
Reference in New Issue
Block a user