aboutsummaryrefslogtreecommitdiff
path: root/backend/ListIterator.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'backend/ListIterator.hpp')
-rw-r--r--backend/ListIterator.hpp41
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;
+}
+