remove revalidation std::list makes it redundant, also realized I can't have a reference in something I default construct
This commit is contained in:
parent
1bfe6e806a
commit
22bfd729e4
1 changed files with 2 additions and 8 deletions
10
Map.hpp
10
Map.hpp
|
@ -44,6 +44,7 @@ template <typename Key_T, typename Mapped_T> struct BookKeeping {
|
|||
Self *right;
|
||||
Self *prev;
|
||||
Self *next;
|
||||
BookKeeping(Map<Key_T, Mapped_T> &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() {
|
||||
|
|
Loading…
Reference in a new issue