fix skiplist erase single element

probably extra janky with multimap
This commit is contained in:
2024-04-13 23:43:29 +02:00
parent a6c551e443
commit dc8289ba3d

View File

@@ -316,11 +316,12 @@ protected:
}
// Comparator true if less than, 0 if equal
template<class Comparator>
std::pair<Node *, bool> erase(const const_iterator &k) {
Node *cur = root;
for (int i = curL; i >= 0; i--) {
while (!cur->next[i]->end() && cur->next[i] != k.n)
while (!cur->next[i]->end() && Comparator()(cur->next[i]->get(), *k))
cur = cur->next[i];
toUpdate[i] = cur;
}
@@ -577,7 +578,7 @@ public:
}
iterator erase(const_iterator el) {
std::pair<typename BaseT::Node *, bool> n = BaseT::erase(el);
std::pair<typename BaseT::Node *, bool> n = BaseT::template erase<Cmp>(el);
if (n.first->end()) return end();
return iterator(n.first);
}