Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r49625 - in sandbox/SOC/2006/tree/trunk: . boost/tree libs/tree/test
From: ockham_at_[hidden]
Date: 2008-11-07 12:00:30


Author: bernhard.reiter
Date: 2008-11-07 12:00:29 EST (Fri, 07 Nov 2008)
New Revision: 49625
URL: http://svn.boost.org/trac/boost/changeset/49625

Log:
Get insert_cursor to work with linear (ascending cursor) inorder and postorder algorithm versions.
Text files modified:
   sandbox/SOC/2006/tree/trunk/TODO | 2 --
   sandbox/SOC/2006/tree/trunk/boost/tree/insert_cursor.hpp | 13 ++-----------
   sandbox/SOC/2006/tree/trunk/libs/tree/test/binary_tree_search_test.cpp | 3 ++-
   sandbox/SOC/2006/tree/trunk/libs/tree/test/cursor_algorithm_test.cpp | 7 ++++++-
   sandbox/SOC/2006/tree/trunk/libs/tree/test/test_tree_traversal_data.hpp | 2 +-
   5 files changed, 11 insertions(+), 16 deletions(-)

Modified: sandbox/SOC/2006/tree/trunk/TODO
==============================================================================
--- sandbox/SOC/2006/tree/trunk/TODO (original)
+++ sandbox/SOC/2006/tree/trunk/TODO 2008-11-07 12:00:29 EST (Fri, 07 Nov 2008)
@@ -16,8 +16,6 @@
 General:
 * Remove algorithm overloads for root_tracking_cursors, as track_root is a very
   context dependent thing; so merge it into the general iterative algorithm versions.
-* Get insert_cursor to work with linear (ascending cursor) inorder algorithm
- version.
 * Move some of the secondary stuff to a util/ dir? Is that what they're used for?
 * Redo testing. Right now, it's just chaotic.
 * Fix recursive algorithms for use with forest.

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 2008-11-07 12:00:29 EST (Fri, 07 Nov 2008)
@@ -45,13 +45,12 @@
  {
 protected:
     mutable Tree& tree;
- mutable bool ins;
 public:
     /**
      * For construction, we obviously need a tree and a cursor to work on (i.e., write to).
      */
     explicit insert_cursor(Tree& x, typename Tree::cursor cur)
- : insert_cursor::cursor_adaptor_(cur), tree(x), ins(false) {}
+ : insert_cursor::cursor_adaptor_(cur), tree(x) {}
 
     // Cursor-specific
     typedef insert_cursor<typename Tree::cursor> cursor;
@@ -63,26 +62,18 @@
 
     typename insert_cursor::cursor_adaptor_::reference dereference() const
     {
- if (ins) {
+ if (this->base_reference().parity()) {
             const_cast<typename Tree::cursor&>(this->base_reference())
             = tree.insert(this->base_reference(), typename Tree::value_type());
         }
         return *this->base_reference();
     }
-
- void increment()
- {
- ins = true;
- ++this->base_reference();
- }
 
     void left()
     {
         this->base_reference() =
             tree.insert(this->base_reference(), typename Tree::value_type());
- ins = false;
     }
-
 };
 
 /**

Modified: sandbox/SOC/2006/tree/trunk/libs/tree/test/binary_tree_search_test.cpp
==============================================================================
--- sandbox/SOC/2006/tree/trunk/libs/tree/test/binary_tree_search_test.cpp (original)
+++ sandbox/SOC/2006/tree/trunk/libs/tree/test/binary_tree_search_test.cpp 2008-11-07 12:00:29 EST (Fri, 07 Nov 2008)
@@ -13,6 +13,7 @@
 #define BOOST_TEST_MODULE binary_tree test
 //#define BOOST_TEST_DYN_LINK
 #include <boost/test/included/unit_test.hpp>
+#include <boost/test/parameterized_test.hpp>
 
 #include <list>
 #include <algorithm>
@@ -59,7 +60,7 @@
     BOOST_CHECK_EQUAL(*c, 4);
     BOOST_CHECK_EQUAL(*d, 7);
     BOOST_CHECK_EQUAL(*c.parent(), 4);
- //BOOST_CHECK_EQUAL(inorder::next(c, 2), d);
+ //BOOST_CHECK(next(inorder(), c, 2) == d);
     
     *c.to_parent() = 6;
     validate_test_data_tree(bt);

Modified: sandbox/SOC/2006/tree/trunk/libs/tree/test/cursor_algorithm_test.cpp
==============================================================================
--- sandbox/SOC/2006/tree/trunk/libs/tree/test/cursor_algorithm_test.cpp (original)
+++ sandbox/SOC/2006/tree/trunk/libs/tree/test/cursor_algorithm_test.cpp 2008-11-07 12:00:29 EST (Fri, 07 Nov 2008)
@@ -47,10 +47,15 @@
 {
     //boost::unit_test::unit_test_log.set_threshold_level(boost::unit_test::log_messages ) ;
     bt2.clear();
- l.clear();
+
     boost::tree::copy(Order(), bt.root(), tree_inserter(bt2, bt2.root()), boost::forward_traversal_tag());
     validate_test_data_tree(bt2);
     BOOST_CHECK_EQUAL(size(bt2.root()), size(bt.root()));
+ bt2.clear();
+
+ boost::tree::copy(Order(), bt.root(), tree_inserter(bt2, bt2.root()));
+ validate_test_data_tree(bt2);
+ BOOST_CHECK_EQUAL(size(bt2.root()), size(bt.root()));
 }
 
 BOOST_AUTO_TEST_CASE_TEMPLATE( test_transform, Order, orders)

Modified: sandbox/SOC/2006/tree/trunk/libs/tree/test/test_tree_traversal_data.hpp
==============================================================================
--- sandbox/SOC/2006/tree/trunk/libs/tree/test/test_tree_traversal_data.hpp (original)
+++ sandbox/SOC/2006/tree/trunk/libs/tree/test/test_tree_traversal_data.hpp 2008-11-07 12:00:29 EST (Fri, 07 Nov 2008)
@@ -33,7 +33,7 @@
     // (With two additional nodes: 11 inserted left of 13; 12 right of 11)
     // and in combination with http://en.wikipedia.org/wiki/Tree_traversal#Examples
     // (as tree shapes are equal [apart from the extra nodes])
- void create_test_data_tree(boost::tree::binary_tree<T>& ret)
+ static void create_test_data_tree(boost::tree::binary_tree<T>& ret)
     {
         // For augmented trees. (Why is this necessary? Nothing here is explicit!)
         typedef typename boost::tree::binary_tree<T>::value_type value_type;


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