mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-04 01:05:58 +03:00
AK: Add some more features to Vector iterators.
This commit is contained in:
parent
ae470ec955
commit
52f135fe13
Notes:
sideshowbarker
2024-07-19 13:59:57 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/52f135fe133
16
AK/Vector.h
16
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:
|
||||
|
Loading…
Reference in New Issue
Block a user