Browse Source

RBTree::swap()

git-svn-id: svn://bind10.isc.org/svn/bind10/branches/trac451@4034 e5f2f494-b856-4b98-b285-d166d9295462
Michal Vaner 14 years ago
parent
commit
186097b07f
2 changed files with 40 additions and 0 deletions
  1. 10 0
      src/lib/datasrc/rbtree.h
  2. 30 0
      src/lib/datasrc/tests/rbtree_unittest.cc

+ 10 - 0
src/lib/datasrc/rbtree.h

@@ -294,6 +294,16 @@ public:
     Result insert(const isc::dns::Name& name, RBNode<T>** inserted_node);
     //@}
 
+    /// \brief Swaps two tree's contents.
+    ///
+    /// This acts the same as many std::*.swap functions, exchanges the
+    /// contents. This doesn't throw anything.
+    void swap(RBTree<T>& other) {
+        std::swap(root_, other.root_);
+        std::swap(NULLNODE, other.NULLNODE);
+        std::swap(node_count_, other.node_count_);
+    }
+
 private:
     /// \name RBTree balance functions
     //@{

File diff suppressed because it is too large
+ 30 - 0
src/lib/datasrc/tests/rbtree_unittest.cc