1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 06:57:46 +00:00

AK: Simplify quick_sort() and improve Vector iterators a bit.

This commit is contained in:
Andreas Kling 2019-05-19 01:53:51 +02:00
parent 853597200e
commit 6e305bf838
2 changed files with 24 additions and 30 deletions

View file

@ -316,6 +316,7 @@ public:
Iterator operator-(int value) { return { m_vector, m_index - value }; }
Iterator operator+(int value) { return { m_vector, m_index + value }; }
T& operator*() { return m_vector[m_index]; }
int operator-(const Iterator& other) { return m_index - other.m_index; }
private:
friend class Vector;
Iterator(Vector& vector, int index) : m_vector(vector), m_index(index) { }
@ -335,6 +336,7 @@ public:
ConstIterator operator-(int value) { return { m_vector, m_index - value }; }
ConstIterator operator+(int value) { return { m_vector, m_index + value }; }
const T& operator*() const { return m_vector[m_index]; }
int operator-(const ConstIterator& other) { return m_index - other.m_index; }
private:
friend class Vector;
ConstIterator(const Vector& vector, const int index) : m_vector(vector), m_index(index) { }