From 5c34847218e8d754447f5cf71ed595bbb412eee7 Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Tue, 29 Oct 2024 23:30:57 +0100 Subject: more WIP --- backend/ListIterator.hpp | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 backend/ListIterator.hpp (limited to 'backend/ListIterator.hpp') diff --git a/backend/ListIterator.hpp b/backend/ListIterator.hpp new file mode 100644 index 0000000..5e4ea91 --- /dev/null +++ b/backend/ListIterator.hpp @@ -0,0 +1,41 @@ +#pragma once + +#include "ListIterator.h" + +template +ListRange::ListRange(List & list) : list(list) { } + +template +ListIterator ListRange::begin() const { + return { this->list, 0 }; +} + +template +ListIterator ListRange::end() const { + return { this->list, this->list.size() }; +} + +template +size_t ListRange::size() const { + return this->list.size(); +} + +template +ListIterator::ListIterator(List & list, size_t index) : list(list), index(index) { } + +template +T ListIterator::operator * () const { + return this->list[this->index]; +} + +template +ListIterator & ListIterator::operator ++ () { + this->index++; + return *this; +} + +template +bool ListIterator::operator != (const ListIterator & rhs) const { + return this->index < rhs.index; +} + -- cgit v1.2.3