BAN: Cleanup sorting code

This commit is contained in:
Bananymous 2023-12-07 22:26:58 +02:00
parent e5cab047d6
commit 46c3da71b6
1 changed files with 4 additions and 4 deletions

View File

@ -15,11 +15,11 @@ namespace BAN
swap(*lhs, *rhs); swap(*lhs, *rhs);
} }
namespace detail namespace detail::sort
{ {
template<typename It, typename Comp> template<typename It, typename Comp>
It sort_quick_partition(It begin, It end, Comp comp) It partition(It begin, It end, Comp comp)
{ {
It pivot = prev(end, 1); It pivot = prev(end, 1);
@ -45,7 +45,7 @@ namespace BAN
{ {
if (begin == end || next(begin, 1) == end) if (begin == end || next(begin, 1) == end)
return; return;
It mid = detail::sort_quick_partition(begin, end, comp); It mid = detail::sort::partition(begin, end, comp);
sort_quick(begin, mid, comp); sort_quick(begin, mid, comp);
sort_quick(++mid, end, comp); sort_quick(++mid, end, comp);
} }
@ -53,7 +53,7 @@ namespace BAN
template<typename It, typename Comp = less<typename It::value_type>> template<typename It, typename Comp = less<typename It::value_type>>
void sort_insertion(It begin, It end, Comp comp = {}) void sort_insertion(It begin, It end, Comp comp = {})
{ {
if (begin == end) if (begin == end || next(begin, 1) == end)
return; return;
for (It it1 = next(begin, 1); it1 != end; ++it1) for (It it1 = next(begin, 1); it1 != end; ++it1)
{ {