diff options
author | asynts <asynts@gmail.com> | 2020-09-06 21:14:08 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-09-08 14:01:21 +0200 |
commit | 1b3ecb01a5c6e5fd01e40b60f253ab8ecef0b970 (patch) | |
tree | 376f40ce61328c9a937d5046f7e47e7ad0bfe63e /AK/NonnullPtrVector.h | |
parent | 9648bf4ada00801ceada7f48248e0d9ab598b227 (diff) | |
download | serenity-1b3ecb01a5c6e5fd01e40b60f253ab8ecef0b970.zip |
AK: Add generic SimpleIterator class to replace VectorIterator.
Diffstat (limited to 'AK/NonnullPtrVector.h')
-rw-r--r-- | AK/NonnullPtrVector.h | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/AK/NonnullPtrVector.h b/AK/NonnullPtrVector.h index 61772b4ddc..3698015974 100644 --- a/AK/NonnullPtrVector.h +++ b/AK/NonnullPtrVector.h @@ -51,13 +51,14 @@ public: using Base::size; - using Iterator = VectorIterator<NonnullPtrVector, T>; - Iterator begin() { return Iterator(*this, 0); } - Iterator end() { return Iterator(*this, size()); } + using ConstIterator = SimpleIterator<const NonnullPtrVector, const T>; + using Iterator = SimpleIterator<NonnullPtrVector, T>; - using ConstIterator = VectorIterator<const NonnullPtrVector, const T>; - ConstIterator begin() const { return ConstIterator(*this, 0); } - ConstIterator end() const { return ConstIterator(*this, size()); } + constexpr ConstIterator begin() const { return ConstIterator::begin(*this); } + constexpr Iterator begin() { return Iterator::begin(*this); } + + constexpr ConstIterator end() const { return ConstIterator::end(*this); } + constexpr Iterator end() { return Iterator::end(*this); } PtrType& ptr_at(int index) { return Base::at(index); } const PtrType& ptr_at(int index) const { return Base::at(index); } |