diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-05-19 01:53:51 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-05-19 01:53:51 +0200 |
commit | 6e305bf838eb86d03530be43fee9bd5f3c5d68cd (patch) | |
tree | 682d50942c7eb0f3f1730fe034480cdb2c47367b /AK/Vector.h | |
parent | 853597200e39ac5856372d8223b6fd2170c32b0c (diff) | |
download | serenity-6e305bf838eb86d03530be43fee9bd5f3c5d68cd.zip |
AK: Simplify quick_sort() and improve Vector iterators a bit.
Diffstat (limited to 'AK/Vector.h')
-rw-r--r-- | AK/Vector.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/AK/Vector.h b/AK/Vector.h index f3474b0ee8..be193eca0a 100644 --- a/AK/Vector.h +++ b/AK/Vector.h @@ -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) { } |