summaryrefslogtreecommitdiff
path: root/AK/Vector.h
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-05-19 01:53:51 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-05-19 01:53:51 +0200
commit6e305bf838eb86d03530be43fee9bd5f3c5d68cd (patch)
tree682d50942c7eb0f3f1730fe034480cdb2c47367b /AK/Vector.h
parent853597200e39ac5856372d8223b6fd2170c32b0c (diff)
downloadserenity-6e305bf838eb86d03530be43fee9bd5f3c5d68cd.zip
AK: Simplify quick_sort() and improve Vector iterators a bit.
Diffstat (limited to 'AK/Vector.h')
-rw-r--r--AK/Vector.h2
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) { }