aboutsummaryrefslogtreecommitdiff
path: root/backend/ListIterator.h
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-10-31 14:14:09 +0100
committerLoek Le Blansch <loek@pipeframe.xyz>2024-10-31 14:14:09 +0100
commitf8d8d7499ba4433678db2a68fb1cae74448ca31e (patch)
treefc96bef89fc3206277d1fcf1e3df5ad733b7e652 /backend/ListIterator.h
parenta0e14fa424494ed35da1bd6e5e54bb36178259a7 (diff)
make ListIterator continue working on a changing list
Diffstat (limited to 'backend/ListIterator.h')
-rw-r--r--backend/ListIterator.h16
1 files changed, 8 insertions, 8 deletions
diff --git a/backend/ListIterator.h b/backend/ListIterator.h
index c7fbf4a..3d11806 100644
--- a/backend/ListIterator.h
+++ b/backend/ListIterator.h
@@ -10,30 +10,30 @@ class List;
template <typename T>
class ListIterator {
public:
- ListIterator(const List<T> & list, size_t index);
+ ListIterator(ListLink<T> * & here);
public:
- T operator * () const;
+ T & operator * () const;
ListIterator<T> & operator ++ ();
bool operator != (const ListIterator<T> &) const;
private:
- const List<T> & list;
- size_t index;
+ ListLink<T> * here = nullptr;
+ ListLink<T> * next = nullptr;
};
template <typename T>
class ListRange {
public:
- ListRange(const List<T> & list);
+ ListRange(List<T> & list);
public:
- ListIterator<T> begin() const;
- ListIterator<T> end() const;
+ ListIterator<T> begin();
+ ListIterator<T> end();
size_t size() const;
private:
- const List<T> & list;
+ List<T> & list;
};
#include "ListIterator.hpp"