Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r48901 - in sandbox/SOC/2006/tree/trunk: . boost/tree/detail/algorithm/cursor boost/tree/detail/cursor
From: ockham_at_[hidden]
Date: 2008-09-19 13:00:09


Author: bernhard.reiter
Date: 2008-09-19 13:00:08 EDT (Fri, 19 Sep 2008)
New Revision: 48901
URL: http://svn.boost.org/trac/boost/changeset/48901

Log:
Introduce iterative *order::foreach algorithms.
Added:
   sandbox/SOC/2006/tree/trunk/boost/tree/detail/algorithm/cursor/_order_iterative.hpp (contents, props changed)
Text files modified:
   sandbox/SOC/2006/tree/trunk/TODO | 2 ++
   sandbox/SOC/2006/tree/trunk/boost/tree/detail/algorithm/cursor/inorder.hpp | 7 +++++++
   sandbox/SOC/2006/tree/trunk/boost/tree/detail/algorithm/cursor/postorder.hpp | 6 ++++++
   sandbox/SOC/2006/tree/trunk/boost/tree/detail/algorithm/cursor/preorder.hpp | 8 +++++++-
   sandbox/SOC/2006/tree/trunk/boost/tree/detail/cursor/forest.hpp | 2 +-
   5 files changed, 23 insertions(+), 2 deletions(-)

Modified: sandbox/SOC/2006/tree/trunk/TODO
==============================================================================
--- sandbox/SOC/2006/tree/trunk/TODO (original)
+++ sandbox/SOC/2006/tree/trunk/TODO 2008-09-19 13:00:08 EDT (Fri, 19 Sep 2008)
@@ -18,6 +18,8 @@
 * Think of a couple good examples (draw inspiration eg from Wikipedia: Tree traversal
   or CRLS) and include them in the docs. Maybe move some files from libs/test to
   example.
+ Eg.: maybe use preorder::copy in combination with an inserting cursor to "physically"
+ copy a tree?
 * Migrate to using Jamfile.v2 from Intrusive (already used in our libs/example dir)
 * Add performance checks (to a libs/perf/ directory).
 * Look into SOC 2008 projects dsearch (already using concepts from Boost.Tree) and

Added: sandbox/SOC/2006/tree/trunk/boost/tree/detail/algorithm/cursor/_order_iterative.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2006/tree/trunk/boost/tree/detail/algorithm/cursor/_order_iterative.hpp 2008-09-19 13:00:08 EDT (Fri, 19 Sep 2008)
@@ -0,0 +1,33 @@
+// Copyright (c) 2006-2008, Bernhard Reiter
+//
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+/** @file _order.hpp
+ *
+ * Some "linear" algorithms that are identical for all *order cursors
+ * (as we are just calling the appropriate traversal function that are
+ * defined in the respective *order.hpp files).
+ */
+
+// NO guards, as this is context-included!
+
+template <class Cursor, class Op>
+Op for_each(root_tracking_cursor<Cursor> s, Op f)
+{
+ root_tracking_cursor<Cursor> t = last(s);
+ s = first(s);
+ while (s!=t) {
+ f(*s);
+ forward(s);
+ }
+ return f;
+}
+
+
+template <class Cursor, class Op>
+Op for_each(Cursor s, Op f)
+{
+ return for_each(root_tracking_cursor<Cursor>(s), f);
+}
\ No newline at end of file

Modified: sandbox/SOC/2006/tree/trunk/boost/tree/detail/algorithm/cursor/inorder.hpp
==============================================================================
--- sandbox/SOC/2006/tree/trunk/boost/tree/detail/algorithm/cursor/inorder.hpp (original)
+++ sandbox/SOC/2006/tree/trunk/boost/tree/detail/algorithm/cursor/inorder.hpp 2008-09-19 13:00:08 EDT (Fri, 19 Sep 2008)
@@ -14,6 +14,8 @@
 #ifndef BOOST_TREE_DETAIL_ALGORITHM_CURSOR_INORDER_HPP
 #define BOOST_TREE_DETAIL_ALGORITHM_CURSOR_INORDER_HPP
 
+#include <boost/tree/root_tracking_cursor.hpp>
+
 #include <algorithm>
 
 namespace boost {
@@ -121,6 +123,7 @@
 
 /*\@}*/
 
+#ifdef BOOST_RECURSIVE_ORDER_ALGORITHMS
 /**
  * @if maint
  * Helper function for for_each, using a reference parameter in order to
@@ -173,6 +176,10 @@
     return f;
 }
 
+#else
+#include <boost/tree/detail/algorithm/cursor/_order_iterative.hpp>
+#endif //BOOST_RECURSIVE_ORDER_ALGORITHMS
+
 /**
  * @brief Copies the subtree s into t, by traversing s in inorder.
  * @param s An input cursor.

Modified: sandbox/SOC/2006/tree/trunk/boost/tree/detail/algorithm/cursor/postorder.hpp
==============================================================================
--- sandbox/SOC/2006/tree/trunk/boost/tree/detail/algorithm/cursor/postorder.hpp (original)
+++ sandbox/SOC/2006/tree/trunk/boost/tree/detail/algorithm/cursor/postorder.hpp 2008-09-19 13:00:08 EDT (Fri, 19 Sep 2008)
@@ -14,6 +14,7 @@
 #ifndef BOOST_TREE_DETAIL_ALGORITHM_CURSOR_POSTORDER_HPP
 #define BOOST_TREE_DETAIL_ALGORITHM_CURSOR_POSTORDER_HPP
 
+#include <boost/tree/root_tracking_cursor.hpp>
 
 namespace boost {
 namespace tree {
@@ -148,6 +149,7 @@
 
 /*\@}*/
 
+#ifdef BOOST_RECURSIVE_ORDER_ALGORITHMS
 /**
  * @if maint
  * Helper function for for_each, using a reference parameter in order to
@@ -198,6 +200,10 @@
     return f;
 }
 
+#else
+#include <boost/tree/detail/algorithm/cursor/_order_iterative.hpp>
+#endif //BOOST_RECURSIVE_ORDER_ALGORITHMS
+
 /**
  * @brief Copies the subtree s into t, by traversing s in postorder.
  * @param s An input cursor.

Modified: sandbox/SOC/2006/tree/trunk/boost/tree/detail/algorithm/cursor/preorder.hpp
==============================================================================
--- sandbox/SOC/2006/tree/trunk/boost/tree/detail/algorithm/cursor/preorder.hpp (original)
+++ sandbox/SOC/2006/tree/trunk/boost/tree/detail/algorithm/cursor/preorder.hpp 2008-09-19 13:00:08 EDT (Fri, 19 Sep 2008)
@@ -14,6 +14,7 @@
 #ifndef BOOST_TREE_DETAIL_ALGORITHM_CURSOR_PREORDER_HPP
 #define BOOST_TREE_DETAIL_ALGORITHM_CURSOR_PREORDER_HPP
 
+#include <boost/tree/root_tracking_cursor.hpp>
 
 namespace boost {
 namespace tree {
@@ -145,6 +146,7 @@
 
 /*\@}*/
 
+#ifdef BOOST_RECURSIVE_ORDER_ALGORITHMS
 /**
  * @if maint
  * Helper function for for_each, using a reference parameter in order to
@@ -176,7 +178,7 @@
  * preorder. @p f must not modify the order of the sequence.
  * If @p f has a return value it is ignored.
  */
- //[ preorder_for_each
+//[ preorder_for_each
 template <class Cursor, class Op>
 Op for_each(Cursor s, Op f)
 //]
@@ -195,6 +197,10 @@
     return f;
 }
 
+#else
+#include <boost/tree/detail/algorithm/cursor/_order_iterative.hpp>
+#endif //BOOST_RECURSIVE_ORDER_ALGORITHMS
+
 /**
  * @brief Copies the subtree s into t, by traversing s in preorder.
  * @param s An input cursor.

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-09-19 13:00:08 EDT (Fri, 19 Sep 2008)
@@ -49,7 +49,7 @@
     typedef Cursor base_cursor;
     
      typedef forest_cursor<Cursor> cursor;
- //typedef const_forest_cursor<Cursor> const_cursor;
+ typedef forest_cursor<Cursor const> const_cursor; //FIXME (?)
 
     //typedef typename cursor_size<base_cursor>::type size_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