Boost logo

Boost-Commit :

From: ockham_at_[hidden]
Date: 2008-06-27 14:01:28


Author: bernhard.reiter
Date: 2008-06-27 14:01:27 EDT (Fri, 27 Jun 2008)
New Revision: 46784
URL: http://svn.boost.org/trac/boost/changeset/46784

Log:
Some more forest related fixes.
Text files modified:
   sandbox/SOC/2006/tree/trunk/boost/tree/detail/cursor/forest.hpp | 27 +++++++++++++++++----------
   sandbox/SOC/2006/tree/trunk/libs/tree/test/forest_tree_test.cpp | 8 ++++----
   sandbox/SOC/2006/tree/trunk/libs/tree/test/test_tree_traversal_data.hpp | 4 ++--
   3 files changed, 23 insertions(+), 16 deletions(-)

Modified: sandbox/SOC/2006/tree/trunk/boost/tree/detail/cursor/forest.hpp
==============================================================================
--- sandbox/SOC/2006/tree/trunk/boost/tree/detail/cursor/forest.hpp (original)
+++ sandbox/SOC/2006/tree/trunk/boost/tree/detail/cursor/forest.hpp 2008-06-27 14:01:27 EDT (Fri, 27 Jun 2008)
@@ -34,16 +34,16 @@
 
 template <class Cursor>
 class forest_cursor
- : public cursor_adaptor<forest_cursor<Cursor>
+: public cursor_adaptor<forest_cursor<Cursor>
       , Cursor
       , boost::use_default
       , bidirectional_traversal_tag
       , forward_traversal_tag
> {
- private:
+private:
     struct enabler {};
 
- public:
+public:
          //TODO: Tidy up typedefs
 
         typedef Cursor base_cursor;
@@ -82,22 +82,30 @@
                 return this->base();
         }
         
- private:
+private:
         
     friend class cursor_core_access;
     friend class iterator_core_access;
-
- void increment()
+
+// bool empty_() const
+// {
+// }
+
+ void increment()
     {
- (++this->base_reference()).to_begin();
+ if (!(++this->base_reference()).empty())
+ this->base_reference().to_begin();
     }
     
     void decrement()
     {
- --this->base_reference().to_parent();
+ if (!this->base_reference().parity())
+ this->base_reference().to_parent();
+ --this->base_reference();
     }
         
         // Range stuff.
+
         // left() remains unchanged, so no need to re-implement it.
 
         void right()
@@ -109,9 +117,8 @@
         
         void up()
         {
- if (!this->base_reference().parity()) {
+ if (!this->base_reference().parity())
                         this->base_reference().to_parent();
- }
         }
 };
 

Modified: sandbox/SOC/2006/tree/trunk/libs/tree/test/forest_tree_test.cpp
==============================================================================
--- sandbox/SOC/2006/tree/trunk/libs/tree/test/forest_tree_test.cpp (original)
+++ sandbox/SOC/2006/tree/trunk/libs/tree/test/forest_tree_test.cpp 2008-06-27 14:01:27 EDT (Fri, 27 Jun 2008)
@@ -42,7 +42,7 @@
 
         c = mytree.insert(c, 4);
         BOOST_CHECK(*c == 4);
- BOOST_CHECK(c == mytree.root().begin()); // Do we want this?
+ BOOST_CHECK(c == mytree.root().begin());
         
         cur = tree_type::base_cursor(c);
 // BOOST_CHECK(cur == mytree.h.root().begin());
@@ -73,7 +73,7 @@
         tree_type forest;
         //create_test_data_tree(forest);
         c = forest.insert(forest.root(), 8);
- BOOST_CHECK(c == forest.root().begin()); // Do we want this?
+ BOOST_CHECK(c == forest.root().begin());
         BOOST_CHECK(*c == 8);
         c = forest.insert(c, 3);
         BOOST_CHECK(*c == 3);
@@ -105,8 +105,8 @@
         back_insert_iter_list_int it_test_list = std::back_inserter(test_list);
         oc_bi_lst_type oc_test_list = oc_bi_lst_type(it_test_list);
         
- //boost::tree::preorder::copy(ft.root(), oc_test_list);
- //test::preorder::traversal(test_list.begin(), test_list.end());
+// boost::tree::preorder::copy(ft.root(), oc_test_list);
+// test::preorder::traversal(test_list.begin(), test_list.end());
         
         test_list.clear();
         //boost::tree::postorder::copy(ft.root(), oc_test_list);

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-06-27 14:01:27 EDT (Fri, 27 Jun 2008)
@@ -66,8 +66,8 @@
         c = t.root().begin();
         BOOST_CHECK(*++c == 10);
         BOOST_CHECK(*++c == 14);
- //BOOST_CHECK(++c == t.root().end());
- //--c;
+ BOOST_CHECK(++c == t.root().end());
+ --c;
         BOOST_CHECK(*c.to_begin() == 13);
         BOOST_CHECK(*c.to_begin() == 11);
         BOOST_CHECK(*++c == 12);


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