Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r55527 - in sandbox/SOC/2006/tree/trunk/boost/tree: . detail
From: ockham_at_[hidden]
Date: 2009-08-11 11:32:54


Author: bernhard.reiter
Date: 2009-08-11 11:32:53 EDT (Tue, 11 Aug 2009)
New Revision: 55527
URL: http://svn.boost.org/trac/boost/changeset/55527

Log:
Some work on detach implementation
Text files modified:
   sandbox/SOC/2006/tree/trunk/boost/tree/binary_tree.hpp | 5 ++---
   sandbox/SOC/2006/tree/trunk/boost/tree/detail/nary_node.hpp | 24 +++++++++++-------------
   2 files changed, 13 insertions(+), 16 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-11 11:32:53 EDT (Tue, 11 Aug 2009)
@@ -352,12 +352,11 @@
      */
     cursor erase(cursor position)
     {
- size_type idx = index(position);
         node_pointer p_node = static_cast<node_pointer>(position.parent_node());
 
- p_node = static_cast<node_pointer>(p_node->detach(idx));
+ detach(position.parent_node(), position.child_node());
 
- position.parent_node() = static_cast<node_base_pointer>(p_node->m_children[idx]);
+ position.parent_node() = static_cast<node_base_pointer>(position.child_node());
 
         m_node_alloc.destroy(p_node);
         m_node_alloc.deallocate(p_node, 1);

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-11 11:32:53 EDT (Tue, 11 Aug 2009)
@@ -94,19 +94,6 @@
 
     node_base(ascending_node_base* p)
     : ascending_node_base(p), descending_node_base() {}
-
- node_base* detach(children_type::size_type m_pos)
- {
- descending_node_base::children_type::size_type parent_idx = get_index();
-
- if (m_children[m_pos] != 0) // Set child's parent only if there _is_ a child
- static_cast<node_base*>(m_children[m_pos])->m_parent = m_parent;
-
- static_cast<node_base*>(m_parent)->m_children[parent_idx]
- = m_children[m_pos];
-
- return &*this;
- }
 
     // O(1)
     children_type::size_type const get_index() const
@@ -115,6 +102,17 @@
     }
 };
 
+void detach(node_base* n, descending_node_base* child)
+{
+ descending_node_base::children_type::size_type parent_idx = n->get_index();
+
+ if (child != 0) // Set child's parent only if there _is_ a child
+ static_cast<node_base*>(child)->m_parent = n->m_parent;
+
+ static_cast<node_base*>(n->m_parent)->m_children[parent_idx]
+ = child;
+}
+
 //descending_node_base::children_type::size_type
 void
 rotate(descending_node_base*& child, node_base* parent


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