Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r50483 - in sandbox/SOC/2006/tree/trunk: . boost/tree libs/tree/test
From: ockham_at_[hidden]
Date: 2009-01-05 07:17:34


Author: bernhard.reiter
Date: 2009-01-05 07:17:33 EST (Mon, 05 Jan 2009)
New Revision: 50483
URL: http://svn.boost.org/trac/boost/changeset/50483

Log:
Fix insert cursor.
Text files modified:
   sandbox/SOC/2006/tree/trunk/TODO | 1 -
   sandbox/SOC/2006/tree/trunk/boost/tree/ascending_cursor.hpp | 1 +
   sandbox/SOC/2006/tree/trunk/boost/tree/insert_cursor.hpp | 8 ++++++--
   sandbox/SOC/2006/tree/trunk/libs/tree/test/insert_cursor_test.cpp | 9 ++++++++-
   4 files changed, 15 insertions(+), 4 deletions(-)

Modified: sandbox/SOC/2006/tree/trunk/TODO
==============================================================================
--- sandbox/SOC/2006/tree/trunk/TODO (original)
+++ sandbox/SOC/2006/tree/trunk/TODO 2009-01-05 07:17:33 EST (Mon, 05 Jan 2009)
@@ -15,7 +15,6 @@
 
 General:
 * preorder_insert_cursor: hopefully easy to implement...
-* Fix insert cursor to work with filling procedure as of insert_cursor_test.cpp
 * Fix insert cursor (test) to work with fake_binary_tree
 * Fix binary tree/node: empty() -> root.begin() == root.end() !
 * Check forest/binary_tree correspondence in a hard wired fashion.

Modified: sandbox/SOC/2006/tree/trunk/boost/tree/ascending_cursor.hpp
==============================================================================
--- sandbox/SOC/2006/tree/trunk/boost/tree/ascending_cursor.hpp (original)
+++ sandbox/SOC/2006/tree/trunk/boost/tree/ascending_cursor.hpp 2009-01-05 07:17:33 EST (Mon, 05 Jan 2009)
@@ -30,6 +30,7 @@
 namespace tree {
 
 /** \addtogroup cursor_adaptors
+ * Predefined cursor adaptors equip a given cursor with additional properties.
  * \@{ */
  
 struct ascending;

Modified: sandbox/SOC/2006/tree/trunk/boost/tree/insert_cursor.hpp
==============================================================================
--- sandbox/SOC/2006/tree/trunk/boost/tree/insert_cursor.hpp (original)
+++ sandbox/SOC/2006/tree/trunk/boost/tree/insert_cursor.hpp 2009-01-05 07:17:33 EST (Mon, 05 Jan 2009)
@@ -63,6 +63,9 @@
     explicit insert_cursor(Tr& x, typename Tr::cursor cur)
     : insert_cursor::cursor_adaptor_(cur), tree(x) {}
 
+ insert_cursor(insert_cursor const& other)
+ : insert_cursor::cursor_adaptor_(other.base()), tree(other.tree) {}
+
     // Cursor-specific
     typedef insert_cursor<typename Tr::cursor> cursor;
     typedef insert_cursor<typename Tr::const_cursor> const_cursor;
@@ -88,8 +91,9 @@
 
     void left()
     {
- this->base_reference() =
- tree.insert(this->base_reference(), typename Tr::value_type());
+ if (this->base_reference().empty())
+ this->base_reference() =
+ tree.insert(this->base_reference(), typename Tr::value_type());
         this->base_reference().to_begin();
     }
 };

Modified: sandbox/SOC/2006/tree/trunk/libs/tree/test/insert_cursor_test.cpp
==============================================================================
--- sandbox/SOC/2006/tree/trunk/libs/tree/test/insert_cursor_test.cpp (original)
+++ sandbox/SOC/2006/tree/trunk/libs/tree/test/insert_cursor_test.cpp 2009-01-05 07:17:33 EST (Mon, 05 Jan 2009)
@@ -29,6 +29,7 @@
 template <class Cursor>
 void fill_subtree_with_data(Cursor cur)
 {
+ //cur.to_begin();
     *cur.begin() = 8;
     *cur.begin().begin() = 3;
     *cur.begin().begin().begin() = 1; //Leaf
@@ -148,7 +149,13 @@
     validate_test_dataset1_tree(bt2.root());
 }
 
-// FIXME: Should also work with fill_subtree_with_data
+BOOST_AUTO_TEST_CASE ( test_desc_copy_using_insert_cursor )
+{
+ bt2.clear();
+ fill_subtree_with_data(tree_inserter(bt2, bt2.root()));
+
+ validate_test_dataset1_tree(bt2.root());
+}
 
 //BOOST_AUTO_TEST_CASE_TEMPLATE ( test_asc_copy_using_insert_cursor, Order, orders )
 //{


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