From 91e78fd746a9eddabf42e2f2ae5ad2f015a7403b Mon Sep 17 00:00:00 2001 From: Christian Mazakas Date: Mon, 25 Jul 2022 11:35:23 -0700 Subject: [PATCH] Add `erase_node()` function to table, creating an optimizer-friendly function --- .../boost/unordered/detail/implementation.hpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/include/boost/unordered/detail/implementation.hpp b/include/boost/unordered/detail/implementation.hpp index cec99c79..2cc27c5d 100644 --- a/include/boost/unordered/detail/implementation.hpp +++ b/include/boost/unordered/detail/implementation.hpp @@ -2928,6 +2928,23 @@ namespace boost { return 1; } + iterator erase_node(c_iterator pos) { + c_iterator next = pos; + ++next; + + bucket_iterator itb = pos.itb; + node_pointer* pp = boost::addressof(itb->next); + while (*pp != pos.p) { + pp = boost::addressof((*pp)->next); + } + + buckets_.extract_node_after(itb, pp); + this->delete_node(pos.p); + --size_; + + return iterator(next.p, next.itb); + } + iterator erase_nodes_range(c_iterator first, c_iterator last) { if (first == last) {