From 8a73e0d95072df51fbf40305f570f39568778078 Mon Sep 17 00:00:00 2001 From: Pagwin Date: Tue, 19 Nov 2024 13:01:22 -0500 Subject: [PATCH] change iterator structure to actually do an in order iterate --- Map.hpp | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/Map.hpp b/Map.hpp index 448ee01..cc2d08e 100644 --- a/Map.hpp +++ b/Map.hpp @@ -1,6 +1,8 @@ // commenting everything out when I commit so all commits my code technically // compiles #include +#include +#include #include #include #include @@ -24,16 +26,28 @@ public: // TODO: Iterator functionality class Iterator { public: - using underlying = typename std::vector>::iterator; - private: - underlying store_iter; + // in order traversal, deque used as the stack we traverse up after each + // right hand side traversal completes + // + // if a right child exists traverse down to the left most child of that + // child pushing to stack elements that are passed if it doesn't pop from + // the stack + // + std::vector &parent; + std::deque forward_traversal; + std::deque backward_traversal; + std::size_t current; public: Iterator() = delete; - Iterator(underlying iter) : store_iter{iter} {} + Iterator(std::vector &parent, std::size_t current) + : parent{parent}, forward_traversal{}, backward_traversal{}, + current{current} {} ConstIterator to_const() const { return ConstIterator(this); } - Iterator &operator++() { return *this; } + Iterator &operator++() { + // TODO: implement this + } Iterator operator++(int) { Iterator tmp = *this; ++(*this);