diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-10-29 23:30:57 +0100 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-10-29 23:30:57 +0100 |
commit | 5c34847218e8d754447f5cf71ed595bbb412eee7 (patch) | |
tree | 2872948e6d2f566dd66cb1a9b2a5d9900db4c44f /backend/ListIterator.hpp | |
parent | a04cb74fee079e3ee43ae5fae32fc2674409822c (diff) |
more WIP
Diffstat (limited to 'backend/ListIterator.hpp')
-rw-r--r-- | backend/ListIterator.hpp | 41 |
1 files changed, 41 insertions, 0 deletions
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 <typename T> +ListRange<T>::ListRange(List<T> & list) : list(list) { } + +template <typename T> +ListIterator<T> ListRange<T>::begin() const { + return { this->list, 0 }; +} + +template <typename T> +ListIterator<T> ListRange<T>::end() const { + return { this->list, this->list.size() }; +} + +template <typename T> +size_t ListRange<T>::size() const { + return this->list.size(); +} + +template <typename T> +ListIterator<T>::ListIterator(List<T> & list, size_t index) : list(list), index(index) { } + +template <typename T> +T ListIterator<T>::operator * () const { + return this->list[this->index]; +} + +template <typename T> +ListIterator<T> & ListIterator<T>::operator ++ () { + this->index++; + return *this; +} + +template <typename T> +bool ListIterator<T>::operator != (const ListIterator<T> & rhs) const { + return this->index < rhs.index; +} + |