|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r49029 - sandbox/SOC/2006/tree/trunk/boost/tree/detail/algorithm/cursor
From: ockham_at_[hidden]
Date: 2008-09-29 15:03:46
Author: bernhard.reiter
Date: 2008-09-29 15:03:45 EDT (Mon, 29 Sep 2008)
New Revision: 49029
URL: http://svn.boost.org/trac/boost/changeset/49029
Log:
Re-arrange *order algorithms from namespaces to a policy(=template)-based mechanism, part 10.
Text files modified:
sandbox/SOC/2006/tree/trunk/boost/tree/detail/algorithm/cursor/_order.hpp | 31 ++++++++++++------
sandbox/SOC/2006/tree/trunk/boost/tree/detail/algorithm/cursor/_order_iterative.hpp | 66 +++++++++++++++++++++++----------------
2 files changed, 58 insertions(+), 39 deletions(-)
Modified: sandbox/SOC/2006/tree/trunk/boost/tree/detail/algorithm/cursor/_order.hpp
==============================================================================
--- sandbox/SOC/2006/tree/trunk/boost/tree/detail/algorithm/cursor/_order.hpp (original)
+++ sandbox/SOC/2006/tree/trunk/boost/tree/detail/algorithm/cursor/_order.hpp 2008-09-29 15:03:45 EDT (Mon, 29 Sep 2008)
@@ -4,14 +4,18 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
-/** @file _order.hpp
+/** @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).
*/
-// NO guards, as this is context-included!
+#ifndef BOOST_TREE_DETAIL_ALGORITHM_CURSOR_HPP
+#define BOOST_TREE_DETAIL_ALGORITHM_CURSOR_HPP
+
+namespace boost {
+namespace tree {
/**
* @brief Successor
@@ -19,12 +23,12 @@
* @param n Optional parameter to indicate how many steps to move forward
* @return Successor of @a c
*/
-template <class Cursor>
+template <class Order, class Cursor>
inline Cursor next(Cursor c
, typename Cursor::difference_type n = 1)
{
for (; n!=0; --n)
- forward(c);
+ forward<Order>(c);
return c;
}
@@ -34,12 +38,12 @@
* @param n Optional parameter to indicate how many steps to move back
* @return Predecessor of @a c
*/
-template <class Cursor>
+template <class Order, class Cursor>
inline Cursor prior(Cursor c
, typename Cursor::difference_type n = 1)
{
for (; n!=0; --n)
- back(c);
+ back<Order>(c);
return c;
}
@@ -48,10 +52,10 @@
* @param c A cursor
* @return Cursor to the first element of @a c in preorder traversal
*/
-template <class Cursor>
+template <class Order, class Cursor>
Cursor first(Cursor c)
{
- to_first(c);
+ to_first<Order>(c);
return c;
}
@@ -62,9 +66,14 @@
* @return Cursor one position past the last element of @a c in preorder
* traversal
*/
-template <class Cursor>
+template <class Order, class Cursor>
Cursor last(Cursor c)
{
- to_last(c);
+ to_last<Order>(c);
return c;
-}
\ No newline at end of file
+}
+
+} // namespace tree
+} // namespace boost
+
+#endif //BOOST_TREE_DETAIL_ALGORITHM_CURSOR_HPP
\ No newline at end of file
Modified: 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 (original)
+++ sandbox/SOC/2006/tree/trunk/boost/tree/detail/algorithm/cursor/_order_iterative.hpp 2008-09-29 15:03:45 EDT (Mon, 29 Sep 2008)
@@ -4,24 +4,28 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
-/** @file _order_iterative.hpp
+/** @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).
*/
-// NO guards, as this is context-included!
+#ifndef BOOST_TREE_DETAIL_ALGORITHM_CURSOR_ITERATIVE_HPP
+#define BOOST_TREE_DETAIL_ALGORITHM_CURSOR_ITERATIVE_HPP
-template <class Cursor, class Op>
+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(s);
- to_last(s2);
+ to_first<Order>(s);
+ to_last<Order>(s2);
while (s!=s2) {
f(*s);
- forward(s);
+ forward<Order>(s);
}
return f;
}
@@ -37,25 +41,25 @@
* If @p f has a return value it is ignored.
*/
//[ for_each
-template <class Cursor, class Op>
+template <class Order, class Cursor, class Op>
Op for_each(Cursor s, Op f)
//]
{
- return for_each(root_tracking_cursor<Cursor>(s), f);
+ return for_each<Order>(root_tracking_cursor<Cursor>(s), f);
}
-template <class InCursor, class OutCursor>
+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(s);
- to_last(s2);
- to_first(t);
+ to_first<Order>(s);
+ to_last<Order>(s2);
+ to_first<Order>(t);
while (s!=s2) {
*t = *s;
- forward(s);
- forward(t);
+ forward<Order>(s);
+ forward<Order>(t);
}
return t;
}
@@ -66,27 +70,28 @@
* @param t An output cursor.
* @result A cursor past t's *order end, after the copying operation.
*/
-template <class InCursor, class OutCursor>
+template <class Order, class InCursor, class OutCursor>
OutCursor copy (InCursor s, OutCursor t)
{
root_tracking_cursor<OutCursor> u
- = copy(root_tracking_cursor<InCursor>(s)
- , root_tracking_cursor<OutCursor>(t));
+ = copy<Order>(root_tracking_cursor<InCursor>(s)
+ , root_tracking_cursor<OutCursor>(t));
return u.base();
}
-template <class InCursor, class OutCursor, class Op>
+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<OutCursor> t
+ , Op op)
{
root_tracking_cursor<InCursor> s2(s);
- to_first(s);
- to_last(s2);
- to_first(t);
+ to_first<Order>(s);
+ to_last<Order>(s2);
+ to_first<Order>(t);
while (s!=s2) {
*t = op(*s);
- forward(s);
- forward(t);
+ forward<Order>(s);
+ forward<Order>(t);
}
return t;
}
@@ -105,11 +110,16 @@
*
* op must not change its argument.
*/
-template <class InCursor, class OutCursor, class Op>
+template <class Order, class InCursor, class OutCursor, class Op>
OutCursor transform (InCursor s, OutCursor t, Op op)
{
root_tracking_cursor<OutCursor> u
- = transform(root_tracking_cursor<InCursor>(s)
- , root_tracking_cursor<OutCursor>(t), op);
+ = transform<Order>(root_tracking_cursor<InCursor>(s)
+ , root_tracking_cursor<OutCursor>(t), op);
return u.base();
-}
\ No newline at end of file
+}
+
+} // namespace tree
+} // namespace boost
+
+#endif //BOOST_TREE_DETAIL_ALGORITHM_CURSOR_ITERATIVE_HPP
\ No newline at end of file
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