Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r49715 - in sandbox/SOC/2006/tree/trunk: boost/tree libs/tree/test
From: ockham_at_[hidden]
Date: 2008-11-13 07:58:13


Author: bernhard.reiter
Date: 2008-11-13 07:58:12 EST (Thu, 13 Nov 2008)
New Revision: 49715
URL: http://svn.boost.org/trac/boost/changeset/49715

Log:
Slightly change binary_tree insert semantics.
Text files modified:
   sandbox/SOC/2006/tree/trunk/boost/tree/balanced_tree.hpp | 2 +-
   sandbox/SOC/2006/tree/trunk/boost/tree/binary_tree.hpp | 18 ++++++++----------
   sandbox/SOC/2006/tree/trunk/boost/tree/forest_tree.hpp | 2 +-
   sandbox/SOC/2006/tree/trunk/libs/tree/test/binary_tree_test.cpp | 12 ++++++++++--
   4 files changed, 20 insertions(+), 14 deletions(-)

Modified: sandbox/SOC/2006/tree/trunk/boost/tree/balanced_tree.hpp
==============================================================================
--- sandbox/SOC/2006/tree/trunk/boost/tree/balanced_tree.hpp (original)
+++ sandbox/SOC/2006/tree/trunk/boost/tree/balanced_tree.hpp 2008-11-13 07:58:12 EST (Thu, 13 Nov 2008)
@@ -499,7 +499,7 @@
         c = h.insert(c, data_type(val));
         
         balancer_type::add(h, c);
- return iterator(c);
+ return iterator(c.to_begin());
     }
 
     /**

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 2008-11-13 07:58:12 EST (Thu, 13 Nov 2008)
@@ -208,8 +208,6 @@
      */
     cursor insert(cursor pos, value_type const& val)
     {
- //increment size!
-
         void* val_hint = 0;//TODO: need some method to obtain hints from cursor
         void* node_hint = 0;
         
@@ -226,19 +224,19 @@
         if ((pos == this->inorder_first()))
             m_header[1] = p_node;
 
- return pos.begin();
+ return pos;
     }
 
     // TODO: Optimise. Especially wrt header links.
     // Making the other insert() a special case of this one might be more
     // reasonable.
     /**
- * @brief Inserts val in front of @a pos, or, if @a pos' parent is
- * already full, creates a new child node containing @a val
- * instead.
- * @param pos The %binary_tree inorder iterator in front of which to insert.
- * @param val The value to insert.
- * @return An inorder iterator that points to the inserted data.
+ * @brief Inserts val in front of @a pos, or, if @a pos' parent is
+ * already full, creates a new child node containing @a val
+ * instead.
+ * @param pos The %binary_tree inorder iterator in front of which to insert.
+ * @param val The value to insert.
+ * @return An inorder iterator that points to the inserted data.
      */
     template <class InputCursor>
     cursor insert(cursor pos, InputCursor subtree)
@@ -255,7 +253,7 @@
             insert(pos.begin(), subtree);
         if (!(++subtree).empty())
             insert(pos.end(), subtree);
- return pos.begin();
+ return pos;
     }
 
 // //erase operations must rebalance; clear doesn't need to.

Modified: sandbox/SOC/2006/tree/trunk/boost/tree/forest_tree.hpp
==============================================================================
--- sandbox/SOC/2006/tree/trunk/boost/tree/forest_tree.hpp (original)
+++ sandbox/SOC/2006/tree/trunk/boost/tree/forest_tree.hpp 2008-11-13 07:58:12 EST (Thu, 13 Nov 2008)
@@ -106,7 +106,7 @@
      */
     cursor insert(cursor pos, value_type const& val)
     {
- return cursor(h.insert(base_cursor(pos), val).to_parent());
+ return cursor(h.insert(base_cursor(pos), val));
     }
 
     /**

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 2008-11-13 07:58:12 EST (Thu, 13 Nov 2008)
@@ -30,8 +30,9 @@
     binary_tree<int> bt0;
     BOOST_CHECK(bt0.root().empty());
     
- binary_tree<int>::cursor c = bt0.insert(bt0.root()/*.begin()*/, 8);
-
+ binary_tree<int>::cursor c = bt0.insert(bt0.root()/*.begin()*/, 8);
+ c.to_begin();
+
     BOOST_CHECK(c == bt0.root().begin());
     BOOST_CHECK(bt0.root().begin().parent() == bt0.root());
     BOOST_CHECK(!bt0.root().empty());
@@ -39,6 +40,7 @@
     BOOST_CHECK(bt0.root().begin().empty());
     
     c = bt0.insert(c, 3);
+ c.to_begin();
     
     // The 8 valued cursor still ok?
     BOOST_CHECK(bt0.root().begin().parent() == bt0.root());
@@ -71,6 +73,8 @@
     BOOST_CHECK(c.empty());
     
     c1 = mytree.insert(c, 1);
+ c1.to_begin();
+
     BOOST_CHECK_EQUAL(*c1, 1);
     
     BOOST_CHECK(!c.empty());
@@ -78,6 +82,8 @@
     BOOST_CHECK(c1.parent() == c);
     
     c2 = mytree.insert(c1, 2);
+ c2.to_begin();
+
     BOOST_CHECK(!c.empty());
     BOOST_CHECK(c2.empty());
     BOOST_CHECK_EQUAL(*c1, 1);
@@ -102,6 +108,8 @@
     BOOST_CHECK_EQUAL(*c3, 2);
     ++c3;
     c4 = mytree.insert(c3, 4);
+ c4.to_begin();
+
     BOOST_CHECK_EQUAL(*c4, 4);
     c4 = c4.parent();
     --c4;


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