1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 14:07:45 +00:00

AK: Make single pivot quick_sort guarantee a max stack depth of log(n)

- The change to quick_sort requires SimpleIterator to support
  assignment.
- Rename quick_sort to single_pivot_quick_sort to make it easier
  to choose a specific implementation (not based on signature).
- Ensure single_pivot_quick_sort does not copy the pivots
- Expand sorts_without_copy test case to cover both single and dual
  pivot implementations.
This commit is contained in:
Mart G 2021-01-31 13:13:49 +01:00 committed by Andreas Kling
parent 40da077f6c
commit 9068398f6b
3 changed files with 105 additions and 19 deletions

View file

@ -78,6 +78,13 @@ public:
constexpr const ValueType* operator->() const { return &m_container[m_index]; }
constexpr ValueType* operator->() { return &m_container[m_index]; }
SimpleIterator& operator=(const SimpleIterator& other)
{
m_index = other.m_index;
return *this;
}
SimpleIterator(const SimpleIterator& obj) = default;
private:
static constexpr SimpleIterator begin(Container& container) { return { container, 0 }; }
static constexpr SimpleIterator end(Container& container)