about summary refs log tree commit diff
path: root/absl/container/internal
diff options
context:
space:
mode:
Diffstat (limited to 'absl/container/internal')
-rw-r--r--absl/container/internal/btree.h1
-rw-r--r--absl/container/internal/btree_container.h36
-rw-r--r--absl/container/internal/common.h5
3 files changed, 22 insertions, 20 deletions
diff --git a/absl/container/internal/btree.h b/absl/container/internal/btree.h
index cf7ef02cccc5..40217dd5f0a8 100644
--- a/absl/container/internal/btree.h
+++ b/absl/container/internal/btree.h
@@ -2031,7 +2031,6 @@ auto btree<P>::erase(iterator iter) -> iterator {
     iterator internal_iter(iter);
     --iter;
     assert(iter.node->leaf());
-    assert(!compare_keys(internal_iter.key(), iter.key()));
     params_type::move(mutable_allocator(), iter.node->slot(iter.position),
                       internal_iter.node->slot(internal_iter.position));
     internal_delete = true;
diff --git a/absl/container/internal/btree_container.h b/absl/container/internal/btree_container.h
index 726861d5bbb1..774412d91592 100644
--- a/absl/container/internal/btree_container.h
+++ b/absl/container/internal/btree_container.h
@@ -296,9 +296,10 @@ class btree_set_container : public btree_container<Tree> {
   insert_return_type insert(node_type &&node) {
     if (!node) return {this->end(), false, node_type()};
     std::pair<iterator, bool> res =
-        insert(std::move(params_type::element(CommonAccess::GetSlot(node))));
+        this->tree_.insert_unique(params_type::key(CommonAccess::GetSlot(node)),
+                                  CommonAccess::GetSlot(node));
     if (res.second) {
-      CommonAccess::Reset(&node);
+      CommonAccess::Destroy(&node);
       return {res.first, true, node_type()};
     } else {
       return {res.first, false, std::move(node)};
@@ -308,8 +309,8 @@ class btree_set_container : public btree_container<Tree> {
     if (!node) return this->end();
     std::pair<iterator, bool> res = this->tree_.insert_hint_unique(
         iterator(hint), params_type::key(CommonAccess::GetSlot(node)),
-        std::move(params_type::element(CommonAccess::GetSlot(node))));
-    if (res.second) CommonAccess::Reset(&node);
+        CommonAccess::GetSlot(node));
+    if (res.second) CommonAccess::Destroy(&node);
     return res.first;
   }
 
@@ -323,7 +324,7 @@ class btree_set_container : public btree_container<Tree> {
   // Node extraction routines.
   template <typename K = key_type>
   node_type extract(const key_arg<K> &key) {
-    auto it = find(key);
+    auto it = this->find(key);
     return it == this->end() ? node_type() : extract(it);
   }
   using super_type::extract;
@@ -523,24 +524,21 @@ class btree_multiset_container : public btree_container<Tree> {
     return this->tree_.insert_hint_multi(
         iterator(position), init_type(std::forward<Args>(args)...));
   }
-
- private:
-  template <typename... Args>
-  iterator insert_node_helper(node_type &&node, Args &&... args) {
+  iterator insert(node_type &&node) {
     if (!node) return this->end();
     iterator res =
-        insert(std::forward<Args>(args)...,
-               std::move(params_type::element(CommonAccess::GetSlot(node))));
-    CommonAccess::Reset(&node);
+        this->tree_.insert_multi(params_type::key(CommonAccess::GetSlot(node)),
+                                 CommonAccess::GetSlot(node));
+    CommonAccess::Destroy(&node);
     return res;
   }
-
- public:
-  iterator insert(node_type &&node) {
-    return insert_node_helper(std::move(node));
-  }
   iterator insert(const_iterator hint, node_type &&node) {
-    return insert_node_helper(std::move(node), hint);
+    if (!node) return this->end();
+    iterator res = this->tree_.insert_hint_multi(
+        iterator(hint),
+        std::move(params_type::element(CommonAccess::GetSlot(node))));
+    CommonAccess::Destroy(&node);
+    return res;
   }
 
   // Deletion routines.
@@ -553,7 +551,7 @@ class btree_multiset_container : public btree_container<Tree> {
   // Node extraction routines.
   template <typename K = key_type>
   node_type extract(const key_arg<K> &key) {
-    auto it = find(key);
+    auto it = this->find(key);
     return it == this->end() ? node_type() : extract(it);
   }
   using super_type::extract;
diff --git a/absl/container/internal/common.h b/absl/container/internal/common.h
index 4bd5d469746b..cc7633dcfa15 100644
--- a/absl/container/internal/common.h
+++ b/absl/container/internal/common.h
@@ -167,6 +167,11 @@ struct CommonAccess {
   }
 
   template <typename Node>
+  static void Destroy(Node* node) {
+    node->destroy();
+  }
+
+  template <typename Node>
   static void Reset(Node* node) {
     node->reset();
   }