diff --git a/modules/08_stl_algorithms/src/sort_and_find.cpp b/modules/08_stl_algorithms/src/sort_and_find.cpp index 19a7384..fe17fd6 100644 --- a/modules/08_stl_algorithms/src/sort_and_find.cpp +++ b/modules/08_stl_algorithms/src/sort_and_find.cpp @@ -1,9 +1,19 @@ #include "sort_and_find.hpp" +#include + namespace stl_algorithms { -auto sorted_copy(std::vector data) -> std::vector { (void)data; return {}; } -auto contains(const std::vector& data, int value) -> bool { (void)data; (void)value; return false; } -auto lower_bound_index(const std::vector& sorted, int value) -> int { (void)sorted; (void)value; return -1; } +auto sorted_copy(std::vector data) -> std::vector { + std::ranges::sort(data); + return data; +} +auto contains(const std::vector& data, const int value) -> bool { + return std::ranges::find(data, value) != data.end(); +} + +auto lower_bound_index(const std::vector& sorted, const int value) -> int { + return static_cast(std::ranges::lower_bound(sorted, value) - sorted.begin()); +} } // namespace stl_algorithms