Parcourir la source

fix(rbtree): fix rbtree rotate and set copy ctor

greatbridf il y a 1 an
Parent
commit
e991778937
2 fichiers modifiés avec 13 ajouts et 2 suppressions
  1. 5 0
      gblibstdc++/include/bits/rbtree
  2. 8 2
      gblibstdc++/include/set

+ 5 - 0
gblibstdc++/include/bits/rbtree

@@ -399,6 +399,9 @@ public:
         rt->parent = nrt;
 
         rt->right = nrt->left;
+        if (rt->right)
+            rt->right->parent = rt;
+
         nrt->left = rt;
     }
 
@@ -419,6 +422,8 @@ public:
         rt->parent = nrt;
 
         rt->left = nrt->right;
+        if (rt->left)
+            rt->left->parent = rt;
         nrt->right = rt;
     }
 

+ 8 - 2
gblibstdc++/include/set

@@ -74,10 +74,10 @@ public:
         : set(first, last, Compare(), alloc) {}
 
     __GBLIBCPP_CONSTEXPR
-    set(const set& other) : tree(other) {}
+    set(const set& other) : tree(other.tree) {}
     __GBLIBCPP_CONSTEXPR
     set(const set& other, const Allocator& alloc)
-        : tree(other, alloc) { }
+        : tree(other.tree, alloc) { }
 
     __GBLIBCPP_CONSTEXPR
     set(set&& other) : tree(std::move(other.tree)) {}
@@ -116,6 +116,12 @@ public:
     iterator find(const Key& key) { return tree.find(key); }
     __GBLIBCPP_CONSTEXPR
     const_iterator find(const Key& key) const { return tree.find(key); }
+    template <typename K>
+    __GBLIBCPP_CONSTEXPR
+    iterator find(const K& key) { return tree.find(key); }
+    template <typename K>
+    __GBLIBCPP_CONSTEXPR
+    const_iterator find(const K& key) const { return tree.find(key); }
 
     __GBLIBCPP_CONSTEXPR
     std::pair<iterator, bool> insert(const value_type& value)