|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r49017 - in sandbox/SOC/2006/tree/trunk: boost/tree boost/tree/detail/algorithm/cursor boost/tree/detail/algorithm/iterator boost/tree/detail/iterator libs/tree/test
From: ockham_at_[hidden]
Date: 2008-09-29 13:59:06
Author: bernhard.reiter
Date: 2008-09-29 13:59:05 EDT (Mon, 29 Sep 2008)
New Revision: 49017
URL: http://svn.boost.org/trac/boost/changeset/49017
Log:
Re-arrange *order algorithms from namespaces to a policy(=template)-based mechanism, part 1.
Text files modified:
sandbox/SOC/2006/tree/trunk/boost/tree/balanced_tree.hpp | 8 ++++----
sandbox/SOC/2006/tree/trunk/boost/tree/detail/algorithm/cursor/_order_iterative.hpp | 11 -----------
sandbox/SOC/2006/tree/trunk/boost/tree/detail/algorithm/cursor/inorder.hpp | 2 ++
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 | 6 ++++--
sandbox/SOC/2006/tree/trunk/boost/tree/detail/algorithm/iterator/_order.hpp | 31 +++++++++++++++++--------------
sandbox/SOC/2006/tree/trunk/boost/tree/detail/iterator/_order.hpp | 6 +++---
sandbox/SOC/2006/tree/trunk/boost/tree/multiway_tree.hpp | 4 ++--
sandbox/SOC/2006/tree/trunk/boost/tree/nary_tree.hpp | 4 ++--
sandbox/SOC/2006/tree/trunk/libs/tree/test/forest_tree_test.cpp | 6 +++---
10 files changed, 41 insertions(+), 43 deletions(-)
Modified: sandbox/SOC/2006/tree/trunk/boost/tree/balanced_tree.hpp
==============================================================================
--- sandbox/SOC/2006/tree/trunk/boost/tree/balanced_tree.hpp (original)
+++ sandbox/SOC/2006/tree/trunk/boost/tree/balanced_tree.hpp 2008-09-29 13:59:05 EDT (Mon, 29 Sep 2008)
@@ -97,13 +97,13 @@
template <class Cursor>
class balanced_tree_iterator
-: public inorder::iterator< is_on_top_cursor<Cursor> > {
+: public iterator<inorder, , is_on_top_cursor<Cursor> > {
public:
balanced_tree_iterator()
- : inorder::iterator< is_on_top_cursor<Cursor> >() {}
+ : iterator<inorder, , is_on_top_cursor<Cursor> >() {}
explicit balanced_tree_iterator(Cursor p)
- : inorder::iterator< is_on_top_cursor<Cursor> >(p) {}
+ : iterator<inorder, , is_on_top_cursor<Cursor> >(p) {}
operator Cursor()
{
@@ -513,7 +513,7 @@
void rotate(iterator& i)
{
- cursor c = cursor(inorder::iterator<cursor>(i));
+ cursor c = cursor(iterator<inorder, , cursor>(i));
h.rotate(c);
}
};
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 13:59:05 EDT (Mon, 29 Sep 2008)
@@ -44,17 +44,6 @@
return for_each(root_tracking_cursor<Cursor>(s), f);
}
-// Iterative algorithms involving OutCursors are significantly more complicated,
-// as we need to navigate the OutCursor (say, t) in a fashion parallel to the Incursor
-// (s), eg:
-//
-// forward(s)
-// forward(t)
-//
-// But forward() is a quite complicated algorithm involving checks of parity() or
-// or moving to_parent() -- things that aren't implemented for output cursor
-// adaptors (yet?).
-
template <class InCursor, class OutCursor>
root_tracking_cursor<OutCursor> copy (root_tracking_cursor<InCursor> s
, root_tracking_cursor<OutCursor> t)
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 13:59:05 EDT (Mon, 29 Sep 2008)
@@ -22,6 +22,8 @@
namespace boost {
namespace tree {
+struct inorder {};
+
namespace inorder {
/** \addtogroup traversal */
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 13:59:05 EDT (Mon, 29 Sep 2008)
@@ -17,10 +17,12 @@
#include <boost/tree/root_tracking_cursor.hpp>
#include <boost/tree/ascending_cursor.hpp>
+namespace postorder {
+
namespace boost {
namespace tree {
-
-namespace postorder {
+
+struct postorder {};
/** \addtogroup traversal */
/*\@{*/
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 13:59:05 EDT (Mon, 29 Sep 2008)
@@ -17,10 +17,12 @@
#include <boost/tree/root_tracking_cursor.hpp>
#include <boost/tree/ascending_cursor.hpp>
+namespace preorder {
+
+struct preorder {};
+
namespace boost {
namespace tree {
-
-namespace preorder {
/** \addtogroup traversal */
/*\@{*/
Modified: sandbox/SOC/2006/tree/trunk/boost/tree/detail/algorithm/iterator/_order.hpp
==============================================================================
--- sandbox/SOC/2006/tree/trunk/boost/tree/detail/algorithm/iterator/_order.hpp (original)
+++ sandbox/SOC/2006/tree/trunk/boost/tree/detail/algorithm/iterator/_order.hpp 2008-09-29 13:59:05 EDT (Mon, 29 Sep 2008)
@@ -4,14 +4,15 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
-/** @file _order.hpp
+/** @file iterator.hpp
*
* Some definitions 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_ITERATOR_HPP
+#define BOOST_TREE_DETAIL_ALGORITHM_ITERATOR_HPP
#include <boost/iterator/iterator_adaptor.hpp>
#include <boost/type_traits/is_convertible.hpp>
@@ -25,12 +26,12 @@
* @param c A cursor
* @return Iterator to the first element of @a c
*/
-template <class Cursor>
-iterator<Cursor>
+template <class Order, class Cursor>
+iterator<Order, Cursor>
begin(Cursor c)
{
to_first(c);
- return iterator<Cursor>(c);
+ return iterator<Order, Cursor>(c);
}
/**
@@ -39,26 +40,28 @@
* @param c A cursor
* @return Iterator one position past the last element of @a c
*/
-template <class Cursor>
-iterator<Cursor>
+template <class Order, class Cursor>
+iterator<Order, Cursor>
end(Cursor c)
{
to_last(c);
- return iterator<Cursor>(c);
+ return iterator<Order, Cursor>(c);
}
/// Reverse iterators
-template <class Cursor>
-std::reverse_iterator< iterator<Cursor> >
+template <class Order, class Cursor>
+std::reverse_iterator< iterator<Order, Cursor> >
rbegin(Cursor c)
{
- return std::reverse_iterator< iterator<Cursor> >(end(c));
+ return std::reverse_iterator< iterator<Order, Cursor> >(end(c));
}
-template <class Cursor>
-std::reverse_iterator< iterator<Cursor> >
+template <class Order, class Cursor>
+std::reverse_iterator< iterator<Order, Cursor> >
rend(Cursor c)
{
- return std::reverse_iterator< iterator<Cursor> >(begin(c));
+ return std::reverse_iterator< iterator<Order, Cursor> >(begin(c));
}
+
+#endif BOOST_TREE_DETAIL_ALGORITHM_ITERATOR_HPP
\ No newline at end of file
Modified: sandbox/SOC/2006/tree/trunk/boost/tree/detail/iterator/_order.hpp
==============================================================================
--- sandbox/SOC/2006/tree/trunk/boost/tree/detail/iterator/_order.hpp (original)
+++ sandbox/SOC/2006/tree/trunk/boost/tree/detail/iterator/_order.hpp 2008-09-29 13:59:05 EDT (Mon, 29 Sep 2008)
@@ -23,9 +23,9 @@
* Only works with ascending cursors.
*/
-template <class Cursor>
+template <class Order, class Cursor>
class iterator
- : public boost::iterator_adaptor<iterator<Cursor>
+ : public boost::iterator_adaptor<iterator<Order, Cursor>
, Cursor
, boost::use_default
, bidirectional_traversal_tag
@@ -42,7 +42,7 @@
template <class OtherCursor>
iterator(
- iterator<OtherCursor> const& other
+ iterator<Order, OtherCursor> const& other
, typename boost::enable_if<
boost::is_convertible<OtherCursor, Cursor>
, enabler
Modified: sandbox/SOC/2006/tree/trunk/boost/tree/multiway_tree.hpp
==============================================================================
--- sandbox/SOC/2006/tree/trunk/boost/tree/multiway_tree.hpp (original)
+++ sandbox/SOC/2006/tree/trunk/boost/tree/multiway_tree.hpp 2008-09-29 13:59:05 EDT (Mon, 29 Sep 2008)
@@ -52,8 +52,8 @@
typedef multiway_tree_cursor<base_cursor> cursor;
typedef const_multiway_tree_cursor<base_const_cursor> const_cursor;
-// typedef inorder::iterator<cursor> iterator;
-// typedef inorder::iterator<const_cursor> const_iterator;
+// typedef iterator<inorder, , cursor> iterator;
+// typedef iterator<inorder, , const_cursor> const_iterator;
//
// typedef std::reverse_iterator<iterator> reverse_iterator;
// typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
Modified: sandbox/SOC/2006/tree/trunk/boost/tree/nary_tree.hpp
==============================================================================
--- sandbox/SOC/2006/tree/trunk/boost/tree/nary_tree.hpp (original)
+++ sandbox/SOC/2006/tree/trunk/boost/tree/nary_tree.hpp 2008-09-29 13:59:05 EDT (Mon, 29 Sep 2008)
@@ -72,8 +72,8 @@
typedef nary_tree_cursor<node_type> cursor;
typedef nary_tree_cursor<node_type const> const_cursor;
-// typedef inorder::iterator<cursor> iterator;
-// typedef inorder::iterator<const_cursor> const_iterator;
+// typedef iterator<inorder, , cursor> iterator;
+// typedef iterator<inorder, , const_cursor> const_iterator;
// typedef std::reverse_iterator<iterator> reverse_iterator;
// typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
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-09-29 13:59:05 EDT (Mon, 29 Sep 2008)
@@ -99,9 +99,9 @@
//test::preorder::algorithms(ft.root(), ft.root()); // FIXME: Fix algorithms for use in here.
- //boost::tree::postorder::copy(ft.root(), oc_test_list);
- //test::inorder::traversal(test_list.begin(), test_list.end());
- //BOOST_CHECK(test_list.size() == 11);
+ boost::tree::postorder::copy(ft.root(), oc_test_list);
+ test::inorder::traversal(test_list.begin(), test_list.end());
+ BOOST_CHECK(test_list.size() == 11);
}
int test_main(int, char* [])
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