change iterator structure to actually do an in order iterate
This commit is contained in:
parent
a12ee91033
commit
8a73e0d950
1 changed files with 19 additions and 5 deletions
24
Map.hpp
24
Map.hpp
|
@ -1,6 +1,8 @@
|
|||
// commenting everything out when I commit so all commits my code technically
|
||||
// compiles
|
||||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
#include <deque>
|
||||
#include <initializer_list>
|
||||
#include <iterator>
|
||||
#include <optional>
|
||||
|
@ -24,16 +26,28 @@ public:
|
|||
// TODO: Iterator functionality
|
||||
class Iterator {
|
||||
public:
|
||||
using underlying = typename std::vector<std::optional<ValueType>>::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<ValueType> &parent;
|
||||
std::deque<std::size_t> forward_traversal;
|
||||
std::deque<std::size_t> backward_traversal;
|
||||
std::size_t current;
|
||||
|
||||
public:
|
||||
Iterator() = delete;
|
||||
Iterator(underlying iter) : store_iter{iter} {}
|
||||
Iterator(std::vector<ValueType> &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);
|
||||
|
|
Loading…
Reference in a new issue