Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r49030 - in sandbox/SOC/2006/tree/trunk/boost/tree/detail/algorithm: . cursor
From: ockham_at_[hidden]
Date: 2008-09-29 15:09:33


Author: bernhard.reiter
Date: 2008-09-29 15:09:32 EDT (Mon, 29 Sep 2008)
New Revision: 49030
URL: http://svn.boost.org/trac/boost/changeset/49030

Log:
Re-arrange *order algorithms from namespaces to a policy(=template)-based mechanism, part 11.
Added:
   sandbox/SOC/2006/tree/trunk/boost/tree/detail/algorithm/cursor.hpp (contents, props changed)
   sandbox/SOC/2006/tree/trunk/boost/tree/detail/algorithm/cursor/iterative.hpp
      - copied unchanged from r49029, /sandbox/SOC/2006/tree/trunk/boost/tree/detail/algorithm/cursor/_order_iterative.hpp
Removed:
   sandbox/SOC/2006/tree/trunk/boost/tree/detail/algorithm/cursor/_order.hpp
   sandbox/SOC/2006/tree/trunk/boost/tree/detail/algorithm/cursor/_order_iterative.hpp
Text files modified:
   sandbox/SOC/2006/tree/trunk/boost/tree/detail/algorithm/cursor/inorder.hpp | 6 +-----
   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 | 4 +---
   3 files changed, 3 insertions(+), 13 deletions(-)

Added: sandbox/SOC/2006/tree/trunk/boost/tree/detail/algorithm/cursor.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2006/tree/trunk/boost/tree/detail/algorithm/cursor.hpp 2008-09-29 15:09:32 EDT (Mon, 29 Sep 2008)
@@ -0,0 +1,87 @@
+// 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 cursor.hpp
+ *
+ * Some algorithm versions 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).
+ */
+
+#ifndef BOOST_TREE_DETAIL_ALGORITHM_CURSOR_HPP
+#define BOOST_TREE_DETAIL_ALGORITHM_CURSOR_HPP
+
+#include <boost/tree/detail/algorithm/cursor/preorder.hpp>
+#include <boost/tree/detail/algorithm/cursor/inorder.hpp>
+#include <boost/tree/detail/algorithm/cursor/postorder.hpp>
+
+#ifndef BOOST_RECURSIVE_ORDER_ALGORITHMS
+#include <boost/tree/detail/algorithm/cursor/iterative.hpp>
+#endif
+
+namespace boost {
+namespace tree {
+
+/**
+ * @brief Successor
+ * @param c A cursor
+ * @param n Optional parameter to indicate how many steps to move forward
+ * @return Successor of @a c
+ */
+template <class Order, class Cursor>
+inline Cursor next(Cursor c
+ , typename Cursor::difference_type n = 1)
+{
+ for (; n!=0; --n)
+ forward<Order>(c);
+ return c;
+}
+
+/**
+ * @brief Predecessor
+ * @param c A cursor
+ * @param n Optional parameter to indicate how many steps to move back
+ * @return Predecessor of @a c
+ */
+template <class Order, class Cursor>
+inline Cursor prior(Cursor c
+ , typename Cursor::difference_type n = 1)
+{
+ for (; n!=0; --n)
+ back<Order>(c);
+ return c;
+}
+
+/**
+ * @brief First element of a subtree in preorder traversal
+ * @param c A cursor
+ * @return Cursor to the first element of @a c in preorder traversal
+ */
+template <class Order, class Cursor>
+Cursor first(Cursor c)
+{
+ to_first<Order>(c);
+ return c;
+}
+
+/**
+ * @brief One position past the last element of a subtree in preorder
+ * traversal
+ * @param c A cursor
+ * @return Cursor one position past the last element of @a c in preorder
+ * traversal
+ */
+template <class Order, class Cursor>
+Cursor last(Cursor c)
+{
+ to_last<Order>(c);
+ return c;
+}
+
+} // namespace tree
+} // namespace boost
+
+#endif //BOOST_TREE_DETAIL_ALGORITHM_CURSOR_HPP
\ No newline at end of file

Deleted: sandbox/SOC/2006/tree/trunk/boost/tree/detail/algorithm/cursor/_order.hpp
==============================================================================
--- sandbox/SOC/2006/tree/trunk/boost/tree/detail/algorithm/cursor/_order.hpp 2008-09-29 15:09:32 EDT (Mon, 29 Sep 2008)
+++ (empty file)
@@ -1,79 +0,0 @@
-// 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 cursor.hpp
- *
- * Some algorithm versions 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).
- */
-
-#ifndef BOOST_TREE_DETAIL_ALGORITHM_CURSOR_HPP
-#define BOOST_TREE_DETAIL_ALGORITHM_CURSOR_HPP
-
-namespace boost {
-namespace tree {
-
-/**
- * @brief Successor
- * @param c A cursor
- * @param n Optional parameter to indicate how many steps to move forward
- * @return Successor of @a c
- */
-template <class Order, class Cursor>
-inline Cursor next(Cursor c
- , typename Cursor::difference_type n = 1)
-{
- for (; n!=0; --n)
- forward<Order>(c);
- return c;
-}
-
-/**
- * @brief Predecessor
- * @param c A cursor
- * @param n Optional parameter to indicate how many steps to move back
- * @return Predecessor of @a c
- */
-template <class Order, class Cursor>
-inline Cursor prior(Cursor c
- , typename Cursor::difference_type n = 1)
-{
- for (; n!=0; --n)
- back<Order>(c);
- return c;
-}
-
-/**
- * @brief First element of a subtree in preorder traversal
- * @param c A cursor
- * @return Cursor to the first element of @a c in preorder traversal
- */
-template <class Order, class Cursor>
-Cursor first(Cursor c)
-{
- to_first<Order>(c);
- return c;
-}
-
-/**
- * @brief One position past the last element of a subtree in preorder
- * traversal
- * @param c A cursor
- * @return Cursor one position past the last element of @a c in preorder
- * traversal
- */
-template <class Order, class Cursor>
-Cursor last(Cursor c)
-{
- to_last<Order>(c);
- return c;
-}
-
-} // namespace tree
-} // namespace boost
-
-#endif //BOOST_TREE_DETAIL_ALGORITHM_CURSOR_HPP
\ No newline at end of file

Deleted: sandbox/SOC/2006/tree/trunk/boost/tree/detail/algorithm/cursor/_order_iterative.hpp
==============================================================================
--- sandbox/SOC/2006/tree/trunk/boost/tree/detail/algorithm/cursor/_order_iterative.hpp 2008-09-29 15:09:32 EDT (Mon, 29 Sep 2008)
+++ (empty file)
@@ -1,125 +0,0 @@
-// 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 iterative.hpp
- *
- * Some iterative algorithm versions 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).
- */
-
-#ifndef BOOST_TREE_DETAIL_ALGORITHM_CURSOR_ITERATIVE_HPP
-#define BOOST_TREE_DETAIL_ALGORITHM_CURSOR_ITERATIVE_HPP
-
-namespace boost {
-namespace tree {
-
-template <class Order, class Cursor, class Op>
-Op for_each(root_tracking_cursor<Cursor> s, Op f)
-{
- root_tracking_cursor<Cursor> s2(s);
- to_first<Order>(s);
- to_last<Order>(s2);
- while (s!=s2) {
- f(*s);
- forward<Order>(s);
- }
- return f;
-}
-
-/**
- * @brief Apply a function to every element of a subtree, in the given order.
- * @param s A cursor.
- * @param f A unary function object.
- * @return @p f
- *
- * Applies the function object @p f to each element in the @p subtree.
- * @p f must not modify the order of the sequence.
- * If @p f has a return value it is ignored.
- */
-//[ for_each
-template <class Order, class Cursor, class Op>
-Op for_each(Cursor s, Op f)
-//]
-{
- return for_each<Order>(root_tracking_cursor<Cursor>(s), f);
-}
-
-template <class Order, class InCursor, class OutCursor>
-root_tracking_cursor<OutCursor> copy (root_tracking_cursor<InCursor> s
- , root_tracking_cursor<OutCursor> t)
-{
- root_tracking_cursor<InCursor> s2(s);
- to_first<Order>(s);
- to_last<Order>(s2);
- to_first<Order>(t);
- while (s!=s2) {
- *t = *s;
- forward<Order>(s);
- forward<Order>(t);
- }
- return t;
-}
-
-/**
- * @brief Copies the subtree s into t, by traversing s in the given order.
- * @param s An input cursor.
- * @param t An output cursor.
- * @result A cursor past t's *order end, after the copying operation.
- */
-template <class Order, class InCursor, class OutCursor>
-OutCursor copy (InCursor s, OutCursor t)
-{
- root_tracking_cursor<OutCursor> u
- = copy<Order>(root_tracking_cursor<InCursor>(s)
- , root_tracking_cursor<OutCursor>(t));
- return u.base();
-}
-
-template <class Order, class InCursor, class OutCursor, class Op>
-root_tracking_cursor<OutCursor> transform (root_tracking_cursor<InCursor> s
- , root_tracking_cursor<OutCursor> t
- , Op op)
-{
- root_tracking_cursor<InCursor> s2(s);
- to_first<Order>(s);
- to_last<Order>(s2);
- to_first<Order>(t);
- while (s!=s2) {
- *t = op(*s);
- forward<Order>(s);
- forward<Order>(t);
- }
- return t;
-}
-
-/**
- * @brief Performs an operation on a subtree, by traversing it in
- * the given order.
- * @param s An input cursor.
- * @param t An output cursor.
- * @param op A unary operation.
- * @result A cursor past t's preorder end, after the transforming has
- * finished.
- *
- * By traversing the input subtree s, apply the operation op
- * to each element and write the result to the output subtree t.
- *
- * op must not change its argument.
- */
-template <class Order, class InCursor, class OutCursor, class Op>
-OutCursor transform (InCursor s, OutCursor t, Op op)
-{
- root_tracking_cursor<OutCursor> u
- = transform<Order>(root_tracking_cursor<InCursor>(s)
- , root_tracking_cursor<OutCursor>(t), op);
- return u.base();
-}
-
-} // namespace tree
-} // namespace boost
-
-#endif //BOOST_TREE_DETAIL_ALGORITHM_CURSOR_ITERATIVE_HPP
\ 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-29 15:09:32 EDT (Mon, 29 Sep 2008)
@@ -89,9 +89,7 @@
 
 /*\@}*/
 
-#ifndef BOOST_RECURSIVE_ORDER_ALGORITHMS
-#include <boost/tree/detail/algorithm/cursor/_order_iterative.hpp>
-#else
+#ifdef BOOST_RECURSIVE_ORDER_ALGORITHMS
 
 /**
  * @if maint
@@ -145,8 +143,6 @@
     return f;
 }
 
-//#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-29 15:09:32 EDT (Mon, 29 Sep 2008)
@@ -119,9 +119,7 @@
 
 /*\@}*/
 
-#ifndef BOOST_RECURSIVE_ORDER_ALGORITHMS
-#include <boost/tree/detail/algorithm/cursor/_order_iterative.hpp>
-#else
+#ifdef BOOST_RECURSIVE_ORDER_ALGORITHMS
 
 /**
  * @if maint
@@ -173,8 +171,6 @@
     return f;
 }
 
-//#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-29 15:09:32 EDT (Mon, 29 Sep 2008)
@@ -114,9 +114,7 @@
 
 /*\@}*/
 
-#ifndef BOOST_RECURSIVE_ORDER_ALGORITHMS
-#include <boost/tree/detail/algorithm/cursor/_order_iterative.hpp>
-#else
+#ifdef BOOST_RECURSIVE_ORDER_ALGORITHMS
 
 /**
  * @if maint


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