From ab0334300e1adcca94b4624fcb925d81a3e084a8 Mon Sep 17 00:00:00 2001 From: chatlanin Date: Thu, 27 Mar 2025 21:57:43 +0300 Subject: [PATCH] fix max and range --- bin/main.cpp | 42 +++++++++++----------- src/hack/{mt/algorithms => math}/max.hpp | 2 +- src/hack/{mt/algorithms => range}/sort.hpp | 2 +- src/meson.build | 5 +-- 4 files changed, 26 insertions(+), 25 deletions(-) rename src/hack/{mt/algorithms => math}/max.hpp (94%) rename src/hack/{mt/algorithms => range}/sort.hpp (95%) diff --git a/bin/main.cpp b/bin/main.cpp index ef80bef..d3fa687 100644 --- a/bin/main.cpp +++ b/bin/main.cpp @@ -3,8 +3,8 @@ #include "hack/logger/logger.hpp" -#include "hack/mt/algorithms/sort.hpp" -#include "hack/mt/algorithms/max.hpp" +#include "hack/range/sort.hpp" +#include "hack/math/max.hpp" #include "hack/patterns/ring_buffer.hpp" @@ -25,23 +25,23 @@ auto main(int argc, char *argv[]) -> int hack::log()(v); } - // // mt::sort - // { - // std::vector v { 4, 4, 6, 1, 4, 3, 2 }; - // std::forward_list l { 8, 7, 5, 9, 0, 1, 3, 2, 6, 4 }; - // - // hack::mt::algorithms::sort(v); - // hack::mt::algorithms::sort(l); - // - // hack::log()(v); - // hack::log()(l); - // } - // - // // mt::max - // { - // int a = 4, b = 5; - // int& c = a; - // hack::log()(hack::mt::algorithms::max(4, 5)); - // hack::log()(hack::mt::algorithms::max(c, b)); - // } + // range::sort + { + std::vector v { 4, 4, 6, 1, 4, 3, 2 }; + std::forward_list l { 8, 7, 5, 9, 0, 1, 3, 2, 6, 4 }; + + hack::range::sort(v); + hack::range::sort(l); + + hack::log()(v); + hack::log()(l); + } + + // math::max + { + int a = 4, b = 5; + int& c = a; + hack::log()(hack::math::max(4, 5)); + hack::log()(hack::math::max(c, b)); + } } diff --git a/src/hack/mt/algorithms/max.hpp b/src/hack/math/max.hpp similarity index 94% rename from src/hack/mt/algorithms/max.hpp rename to src/hack/math/max.hpp index 2f6ab2b..037b998 100755 --- a/src/hack/mt/algorithms/max.hpp +++ b/src/hack/math/max.hpp @@ -3,7 +3,7 @@ #include #include -namespace hack::mt::algorithms +namespace hack::math { // std::common_type_t - делает сравнение по правилу тенарного оператора // и выводит низводящий возвращающий тип. Т.е. если в качестве одного из diff --git a/src/hack/mt/algorithms/sort.hpp b/src/hack/range/sort.hpp similarity index 95% rename from src/hack/mt/algorithms/sort.hpp rename to src/hack/range/sort.hpp index 2949908..f2c2631 100644 --- a/src/hack/mt/algorithms/sort.hpp +++ b/src/hack/range/sort.hpp @@ -2,7 +2,7 @@ #include -namespace hack::mt::algorithms +namespace hack::range { // общая сортировка диапозонов, у кого-то есть своя локалная сортировка, а у кого-то // нет. А тут чтоб не реализовывать, есть общая. diff --git a/src/meson.build b/src/meson.build index b98fa57..0f847e5 100755 --- a/src/meson.build +++ b/src/meson.build @@ -8,8 +8,9 @@ headers = [ 'hack/logger/logger.hpp', - 'hack/mt/algorithms/max.hpp', - 'hack/mt/algorithms/sort.hpp', + 'hack/math/max.hpp', + + 'hack/range/sort.hpp', 'hack/patterns/ring_buffer.hpp',