1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 08:44:58 +00:00

AK: Add generic SimpleIterator class to replace VectorIterator.

This commit is contained in:
asynts 2020-09-06 21:14:08 +02:00 committed by Andreas Kling
parent 9648bf4ada
commit 1b3ecb01a5
8 changed files with 152 additions and 90 deletions

View file

@ -26,8 +26,9 @@
#pragma once
#include <AK/Iterator.h>
#include <AK/Span.h>
#include <AK/Vector.h>
#include <AK/kmalloc.h>
namespace AK {
@ -142,13 +143,14 @@ public:
::swap(m_size, other.m_size);
}
using Iterator = VectorIterator<FixedArray, T>;
Iterator begin() { return Iterator(*this, 0); }
Iterator end() { return Iterator(*this, size()); }
using ConstIterator = SimpleIterator<const FixedArray, const T>;
using Iterator = SimpleIterator<FixedArray, T>;
using ConstIterator = VectorIterator<const FixedArray, const T>;
ConstIterator begin() const { return ConstIterator(*this, 0); }
ConstIterator end() const { return ConstIterator(*this, size()); }
ConstIterator begin() const { return ConstIterator::begin(*this); }
Iterator begin() { return Iterator::begin(*this); }
ConstIterator end() const { return ConstIterator::end(*this); }
Iterator end() { return Iterator::end(*this); }
operator Bytes() { return bytes(); }
operator ReadonlyBytes() const { return bytes(); }