From 22bfd729e4af904729539e051e5b40487bfb590b Mon Sep 17 00:00:00 2001 From: Pagwin Date: Fri, 22 Nov 2024 01:43:37 -0500 Subject: [PATCH] remove revalidation std::list makes it redundant, also realized I can't have a reference in something I default construct --- Map.hpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/Map.hpp b/Map.hpp index 1dff8e0..49254d3 100644 --- a/Map.hpp +++ b/Map.hpp @@ -44,6 +44,7 @@ template struct BookKeeping { Self *right; Self *prev; Self *next; + BookKeeping(Map &container) : container{container} {} // reference to a pointer because the alternatives were worse inline Self *&child(Direction dir) { switch (dir) { @@ -452,7 +453,7 @@ public: if (!ret) { return std::make_pair(Iterator{parent->child(dir)}, ret); } - Node to_insert; + Node to_insert{*this}; to_insert.value = val; this->nodes.push_back(std::move(to_insert)); insert_helper(&nodes.back(), parent, dir); @@ -560,9 +561,7 @@ private: public: // TODO: check that the way of reconnecting next and prev works - // TODO: need to revalidate void erase(Iterator pos) { - auto revalidate_begin = pos.ref->container.begin() - pos.ref->self; auto &container = pos.ref->container; // simple cases Node *ref = pos.ref; @@ -608,11 +607,6 @@ public: else { this->complex_erase(pos); } - // need to revalidate iterators now so future erasures aren't fucked - for (auto iter = container.begin() + revalidate_begin; - iter != container.end(); ++iter) { - iter->self = iter; - } } void erase(const Key_T &key) { this->erase(this->find(key)); } void clear() {