move quicksort partitioner to detail namespace
This commit is contained in:
parent
31a177fc86
commit
ef5cccee73
@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
namespace rexy::cx{
|
namespace rexy::cx{
|
||||||
|
|
||||||
|
namespace detail{
|
||||||
template<class Iter, class Compare>
|
template<class Iter, class Compare>
|
||||||
constexpr Iter qs_partition(Iter left, Iter right, const Compare& cmp)
|
constexpr Iter qs_partition(Iter left, Iter right, const Compare& cmp)
|
||||||
noexcept(std::is_nothrow_invocable<Compare,decltype(*left),decltype(*right)>::value &&
|
noexcept(std::is_nothrow_invocable<Compare,decltype(*left),decltype(*right)>::value &&
|
||||||
@ -46,13 +47,14 @@ namespace rexy::cx{
|
|||||||
cx::swap(*left, *right);
|
cx::swap(*left, *right);
|
||||||
return left;
|
return left;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
template<class Iter, class Compare>
|
template<class Iter, class Compare>
|
||||||
constexpr void quicksort(Iter left, Iter right, const Compare& cmp)
|
constexpr void quicksort(Iter left, Iter right, const Compare& cmp)
|
||||||
noexcept(noexcept(cx::qs_partition(left, right, cmp)))
|
noexcept(noexcept(cx::detail::qs_partition(left, right, cmp)))
|
||||||
{
|
{
|
||||||
while(left < right){
|
while(left < right){
|
||||||
auto real_right = right-1;
|
auto real_right = right-1;
|
||||||
auto pivot = qs_partition(left, real_right, cmp);
|
auto pivot = detail::qs_partition(left, real_right, cmp);
|
||||||
quicksort(left, pivot, cmp);
|
quicksort(left, pivot, cmp);
|
||||||
left = ++pivot;
|
left = ++pivot;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user