|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r55490 - in sandbox/SOC/2006/tree/trunk: boost/tree boost/tree/detail libs/tree/test
From: ockham_at_[hidden]
Date: 2009-08-09 14:34:26
Author: bernhard.reiter
Date: 2009-08-09 14:34:25 EDT (Sun, 09 Aug 2009)
New Revision: 55490
URL: http://svn.boost.org/trac/boost/changeset/55490
Log:
Move splice implementation from binary_tree to nary_node
Text files modified:
sandbox/SOC/2006/tree/trunk/boost/tree/binary_tree.hpp | 9 ++-------
sandbox/SOC/2006/tree/trunk/boost/tree/detail/nary_node.hpp | 14 ++++++++++++++
sandbox/SOC/2006/tree/trunk/libs/tree/test/binary_tree_test.cpp | 4 ++++
3 files changed, 20 insertions(+), 7 deletions(-)
Modified: sandbox/SOC/2006/tree/trunk/boost/tree/binary_tree.hpp
==============================================================================
--- sandbox/SOC/2006/tree/trunk/boost/tree/binary_tree.hpp (original)
+++ sandbox/SOC/2006/tree/trunk/boost/tree/binary_tree.hpp 2009-08-09 14:34:25 EDT (Sun, 09 Aug 2009)
@@ -381,13 +381,8 @@
*/
void splice(cursor position, binary_tree& x, cursor root)
{
- static_cast<node_base_pointer>(root.base_node()->m_children[position.m_pos])->m_parent
- = position.base_node();
-
- position.base_node()->m_children[position.m_pos]
- = root.base_node()->m_children[position.m_pos];
-
- root.base_node()->m_children[position.m_pos] = 0;
+ // x isn't actually used currently...
+ position.base_node()->splice(root.base_node(), position.m_pos);
}
/**
Modified: sandbox/SOC/2006/tree/trunk/boost/tree/detail/nary_node.hpp
==============================================================================
--- sandbox/SOC/2006/tree/trunk/boost/tree/detail/nary_node.hpp (original)
+++ sandbox/SOC/2006/tree/trunk/boost/tree/detail/nary_node.hpp 2009-08-09 14:34:25 EDT (Sun, 09 Aug 2009)
@@ -77,6 +77,13 @@
m_children[m_pos] = p_node;
}
+ void splice(node_with_children_base* p_node, children_type::size_type m_pos)
+ {
+ m_children[m_pos] = p_node->m_children[m_pos];
+
+ p_node->m_children[m_pos] = 0;
+ }
+
//protected:
children_type m_children;
};
@@ -128,6 +135,13 @@
node_with_children_base::attach(p_node, m_pos);
}
+
+ void splice(base_pointer p_node, children_type::size_type m_pos)
+ {
+ static_cast<node_base*>(p_node->m_children[m_pos])->m_parent = this;
+
+ node_with_children_base::splice(p_node, m_pos);
+ }
base_pointer detach(children_type::size_type m_pos)
{
Modified: sandbox/SOC/2006/tree/trunk/libs/tree/test/binary_tree_test.cpp
==============================================================================
--- sandbox/SOC/2006/tree/trunk/libs/tree/test/binary_tree_test.cpp (original)
+++ sandbox/SOC/2006/tree/trunk/libs/tree/test/binary_tree_test.cpp 2009-08-09 14:34:25 EDT (Sun, 09 Aug 2009)
@@ -22,6 +22,10 @@
{
binary_tree<int> bt0;
BOOST_CHECK(bt0.root().is_leaf());
+
+// binary_tree<int>::node_base_type::node_with_children_base** x = bt0.m_header.m_children.data();
+// BOOST_CHECK_EQUAL(++x, &bt0.m_header.m_children.data()[1]);
+
//BOOST_CHECK(bt0.root().begin() == bt0.root().end()); //FIXME
// test with allocator?
}
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk