From f8d8d7499ba4433678db2a68fb1cae74448ca31e Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Thu, 31 Oct 2024 14:14:09 +0100 Subject: make ListIterator continue working on a changing list --- backend/List.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'backend/List.h') diff --git a/backend/List.h b/backend/List.h index 1af0b35..3bdbb23 100644 --- a/backend/List.h +++ b/backend/List.h @@ -10,6 +10,7 @@ class ListIterator; template struct ListLink { + friend class ListIterator; ListLink * prev; ListLink * next; T value; @@ -24,7 +25,7 @@ public: public: size_t size() const; - void push_back(T & el); + void push_back(const T & el); void remove(const T & val); void pop_back(); @@ -33,11 +34,12 @@ public: T & operator [] (size_t index) const; - ListIterator begin() const; - ListIterator end() const; - ListRange range() const; + ListIterator begin(); + ListIterator end(); + ListRange range(); private: + friend class ListRange; ListLink * head = nullptr; ListLink * tail = nullptr; size_t length = 0; -- cgit v1.2.3