Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r55888 - sandbox/statistics/tree/libs/tree/example
From: erwann.rogard_at_[hidden]
Date: 2009-08-30 17:58:15


Author: e_r
Date: 2009-08-30 17:58:14 EDT (Sun, 30 Aug 2009)
New Revision: 55888
URL: http://svn.boost.org/trac/boost/changeset/55888

Log:
m
Text files modified:
   sandbox/statistics/tree/libs/tree/example/tree.cpp | 57 ++++++++++++++++-----------------------
   1 files changed, 23 insertions(+), 34 deletions(-)

Modified: sandbox/statistics/tree/libs/tree/example/tree.cpp
==============================================================================
--- sandbox/statistics/tree/libs/tree/example/tree.cpp (original)
+++ sandbox/statistics/tree/libs/tree/example/tree.cpp 2009-08-30 17:58:14 EDT (Sun, 30 Aug 2009)
@@ -1,28 +1,31 @@
 ///////////////////////////////////////////////////////////////////////////////
-// tree::example::tree.cpp //
+// tree_view::example::tree.cpp //
 // //
 // Copyright 2009 Erwann Rogard. 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) //
 ///////////////////////////////////////////////////////////////////////////////
+#include <boost/format.hpp>
 #include <boost/tree/stage.hpp>
 #include <boost/tree/node.hpp>
+#include <boost/tree/dynamic_stage.hpp>
 #include <libs/tree/example/tree.h>
 
 void example_tree(std::ostream& out){
- out << "-> example_tree ";
+ out << "-> example_tree " << std::endl;
 
     using namespace boost;
     
- const unsigned n = 3;
- typedef tree::dynamic_stage<n> stage_;
- typedef tree::node<n> node_;
+ const unsigned n_branches = 3;
+ typedef tree_view::dynamic_stage<n_branches> stage_;
+ typedef tree_view::node<n_branches> node_;
 
     using namespace boost;
- const unsigned n_j = 3;
+ const unsigned n_stages = 4;
     const node_ root_node;
 
- for(unsigned j = 0; j<n_j; j++){
+ out << (format("{[i(j),i(j+1)) : j=0,...,%1%}:")%(n_stages-1)).str();
+ for(unsigned j = 0; j<n_stages; j++){
         out
             << '('
             << stage_::position_first(j)
@@ -31,10 +34,10 @@
             << ')';
     }
     out << std::endl;
+ node_ the_last = last( root_node, n_stages-1);
 
- unsigned nn = stage_::position_last(n_j)-1;
-
- {
+ { // Visits all nodes from the root node to that prior to the_last
+ out << node_::header << std::endl;
         node_ node = root_node;
         unsigned old_stage = node.stage;
         do{
@@ -44,38 +47,24 @@
             }
             out << node;
         }while(
- position(++node)<nn
- );
- }
- out << std::endl << std::endl;
- {
- node_ node = root_node;
- ++node;
- unsigned old_stage = node.stage;
- do{
- if(node.stage != old_stage){
- out << std::endl;
- old_stage = node.stage;
- }
- out << root(node);
- }while(
- position(++node)<nn
+ ++node< the_last
         );
     }
- out << std::endl << std::endl;
- {
- node_ node = back(root_node,n_j);
+
+ out << std::endl;
+ { // Visits all nodes from that prior to the_last to the root_node
+ out << node_::header;
+ node_ node = the_last;
         
         unsigned old_stage = node.stage;
- do{
+ while(node.stage > 0){
+ --node;
             if(node.stage != old_stage){
- out << std::endl;
                 old_stage = node.stage;
+ out << std::endl;
             }
             out << node;
- }while(
- (--node).stage > 0
- );
+ }
     }
 
     out << " <- ";


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