diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-05-21 01:36:36 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-05-21 01:36:36 +0200 |
commit | 52f135fe133caf5d439bd83d705cdc84293e1f3a (patch) | |
tree | eec9932bed9a3ffd671b704a3862430d722555ff | |
parent | ae470ec9558e5903ff68bd3cf95e1355e5a13c1c (diff) | |
download | serenity-52f135fe133caf5d439bd83d705cdc84293e1f3a.zip |
AK: Add some more features to Vector iterators.
-rw-r--r-- | AK/Vector.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/AK/Vector.h b/AK/Vector.h index be193eca0a..2ebe8f92b1 100644 --- a/AK/Vector.h +++ b/AK/Vector.h @@ -312,9 +312,17 @@ public: bool operator!=(const Iterator& other) { return m_index != other.m_index; } bool operator==(const Iterator& other) { return m_index == other.m_index; } bool operator<(const Iterator& other) { return m_index < other.m_index; } + bool operator>(const Iterator& other) { return m_index > other.m_index; } + bool operator>=(const Iterator& other) { return m_index >= other.m_index; } Iterator& operator++() { ++m_index; return *this; } + Iterator& operator--() { --m_index; return *this; } Iterator operator-(int value) { return { m_vector, m_index - value }; } Iterator operator+(int value) { return { m_vector, m_index + value }; } + Iterator& operator=(const Iterator& other) + { + m_index = other.m_index; + return *this; + } T& operator*() { return m_vector[m_index]; } int operator-(const Iterator& other) { return m_index - other.m_index; } private: @@ -332,9 +340,17 @@ public: bool operator!=(const ConstIterator& other) { return m_index != other.m_index; } bool operator==(const ConstIterator& other) { return m_index == other.m_index; } bool operator<(const ConstIterator& other) { return m_index < other.m_index; } + bool operator>(const ConstIterator& other) { return m_index > other.m_index; } + bool operator>=(const ConstIterator& other) { return m_index >= other.m_index; } ConstIterator& operator++() { ++m_index; return *this; } + ConstIterator& operator--() { --m_index; return *this; } ConstIterator operator-(int value) { return { m_vector, m_index - value }; } ConstIterator operator+(int value) { return { m_vector, m_index + value }; } + ConstIterator& operator=(const ConstIterator& other) + { + m_index = other.m_index; + return *this; + } const T& operator*() const { return m_vector[m_index]; } int operator-(const ConstIterator& other) { return m_index - other.m_index; } private: |