Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r55513 - in sandbox/SOC/2006/tree/trunk/boost/tree: . detail
From: ockham_at_[hidden]
Date: 2009-08-10 19:54:50


Author: bernhard.reiter
Date: 2009-08-10 19:54:49 EDT (Mon, 10 Aug 2009)
New Revision: 55513
URL: http://svn.boost.org/trac/boost/changeset/55513

Log:
More implementation semantics changes (attach, splice)
Text files modified:
   sandbox/SOC/2006/tree/trunk/boost/tree/binary_tree.hpp | 4 +-
   sandbox/SOC/2006/tree/trunk/boost/tree/detail/nary_node.hpp | 54 ++++++++++++++++++++--------------------
   2 files changed, 29 insertions(+), 29 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-10 19:54:49 EDT (Mon, 10 Aug 2009)
@@ -195,7 +195,7 @@
         //m_node_alloc.construct(p_node, val);
         *p_node = node_type(val);
         
- pos.base_node()->attach(p_node, pos.m_pos);
+ detail::attach(pos.base_node(), pos.base_node()->m_children[pos.m_pos], p_node, p_node->m_children[pos.m_pos]);
 
         // Readjust begin
 // if ((pos == this->inorder_first()))
@@ -382,7 +382,7 @@
     void splice(cursor position, binary_tree& x, cursor root)
     {
         // x isn't actually used currently...
- detail::splice(position.base_node(), root.base_node()->m_children[position.m_pos], position.m_pos);
+ detail::splice(position.base_node(), position.base_node()->m_children[position.m_pos], root.base_node()->m_children[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-10 19:54:49 EDT (Mon, 10 Aug 2009)
@@ -45,13 +45,13 @@
     {
         return m_parent;
     }
-
- void attach(node_with_parent_base* p_node)
- {
- p_node->m_parent = this;
- }
 };
 
+void attach(node_with_parent_base* child, node_with_parent_base* parent)
+{
+ child->m_parent = parent;
+}
+
 class node_with_children_base;
 
 class node_with_children_base {
@@ -69,18 +69,18 @@
             m_children[i] = 0;
     }
 
- void attach(node_with_children_base* p_node, children_type::size_type m_pos)
- {
- // Only relevant for non-leaf insertion:
- p_node->m_children[m_pos] = m_children[m_pos];
-
- m_children[m_pos] = p_node;
- }
-
 //protected:
     children_type m_children;
 };
 
+void attach(node_with_children_base*& to, node_with_children_base* p_node, node_with_children_base*& parent)
+{
+ // Only relevant for non-leaf insertion:
+ parent = to;
+
+ to = p_node;
+}
+
 static void splice(node_with_children_base*& to, node_with_children_base*& from)
 {
     to = from;
@@ -123,17 +123,6 @@
         return qp;
         //return (c ? 0 : 1);
     }
-
- void attach(base_pointer p_node, children_type::size_type m_pos)
- {
- node_with_parent_base::attach(p_node);
-
- // Only relevant for non-leaf insertion:
- if (m_children[m_pos] != 0)
- static_cast<node_base*>(m_children[m_pos])->m_parent = p_node;
-
- node_with_children_base::attach(p_node, m_pos);
- }
     
     base_pointer detach(children_type::size_type m_pos)
     {
@@ -156,11 +145,22 @@
     
 };
 
-void splice(node_base* to, node_with_children_base*& from, node_with_children_base::children_type::size_type m_pos)
+void attach(node_base* parent, node_with_children_base*& parent_child, node_base* child, node_with_children_base*& child_child)
+{
+ attach(static_cast<node_with_parent_base*>(child), static_cast<node_with_parent_base*>(parent));
+
+ // Only relevant for non-leaf insertion:
+ if (parent_child != 0)
+ static_cast<node_base*>(parent_child)->m_parent = child;
+
+ attach(parent_child, static_cast<node_with_children_base*>(child), child_child);
+}
+
+void splice(node_base* to_parent, node_with_children_base*& to, node_with_children_base*& from)
 {
- static_cast<node_base*>(from)->m_parent = to;
+ static_cast<node_base*>(from)->m_parent = to_parent;
 
- splice(to->m_children[m_pos], from);
+ splice(to, from);
 }
 
 class descending_node_base


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