Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r59286 - in sandbox/statistics/iterator: boost/iterator libs/iterator/example libs/iterator/src
From: erwann.rogard_at_[hidden]
Date: 2010-01-27 16:37:00


Author: e_r
Date: 2010-01-27 16:36:59 EST (Wed, 27 Jan 2010)
New Revision: 59286
URL: http://svn.boost.org/trac/boost/changeset/59286

Log:
m
Text files modified:
   sandbox/statistics/iterator/boost/iterator/flatten_iterator.hpp | 35 ++++++++++++++++++++++++-----------
   sandbox/statistics/iterator/libs/iterator/example/flatten_iterator.cpp | 21 ++++++++++-----------
   sandbox/statistics/iterator/libs/iterator/example/flatten_iterator.h | 6 +++---
   sandbox/statistics/iterator/libs/iterator/src/main.cpp | 6 ++++--
   4 files changed, 41 insertions(+), 27 deletions(-)

Modified: sandbox/statistics/iterator/boost/iterator/flatten_iterator.hpp
==============================================================================
--- sandbox/statistics/iterator/boost/iterator/flatten_iterator.hpp (original)
+++ sandbox/statistics/iterator/boost/iterator/flatten_iterator.hpp 2010-01-27 16:36:59 EST (Wed, 27 Jan 2010)
@@ -110,18 +110,11 @@
                 return (*this->nb_);
             }
 
- diff_ distance_to()
+ diff_ distance_to(flatten_iterator other)
             {
- diff_ d = 0;
- It it = this->b_;
- if(it!=this->e_){
- d += std::distance(this->nb_,this->ne_);
- ++it;
- }
- while(it<this->e_){
- d += std::distance(boost::begin(*it),boost::end(*it));
- ++it;
- }
+ throw std::runtime_error(
+ "flatten_iterator::distance_to"
+ );
             }
 
             bool equal(const flatten_iterator& rhs)const
@@ -147,6 +140,26 @@
                     this->ne_ = boost::end(*this->b_);
                 }
             }
+
+/*
+ diff_ dist_impl(
+ const flatten_iterator& x,
+ const flatten_iterator& y
+ ){
+ BOOST_ASSERT(x.b_ < y.b_);
+ diff_ d = std::distance(x.nb_,x.ne_);
+ It it = x.b_;
+ while((++it)<y.b_){
+ d += std::distance(boost::begin(*it),boost::end(*it));
+ }
+ BOOST_ASSERT(it == y.b_);
+ if(it!=x.e_){
+ d += std::distance(boost::begin(*it),boost::end(x.nb_));
+ }
+
+ }
+*/
+
         
         };
 

Modified: sandbox/statistics/iterator/libs/iterator/example/flatten_iterator.cpp
==============================================================================
--- sandbox/statistics/iterator/libs/iterator/example/flatten_iterator.cpp (original)
+++ sandbox/statistics/iterator/libs/iterator/example/flatten_iterator.cpp 2010-01-27 16:36:59 EST (Wed, 27 Jan 2010)
@@ -1,9 +1,6 @@
 ///////////////////////////////////////////////////////////////////////////////
 // example::iterator::flatten_iterator.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 <iostream>
 #include <boost/assign/std/vector.hpp>
@@ -14,8 +11,8 @@
 #include <boost/range/flatten_range.hpp>
 #include <libs/iterator/example/flatten_iterator.h>
 
-void example_flatten_iterator(std::ostream& out){
- out << "->example_flatten_iterator : ";
+void example_flatten_iterator(std::ostream& os){
+ os << "->example_flatten_iterator : ";
 
     using namespace boost;
 
@@ -24,7 +21,6 @@
     typedef range_size<vals_>::type size_;
         typedef std::vector<vals_> mat_;
 
- vals_ vals1, vals2, vals3;
         mat_ mat;
     {
             using namespace boost::assign;
@@ -43,14 +39,17 @@
                 int j = 0;
             int n = std::distance(b,e);
             BOOST_ASSERT(
- n == boost::size(vals1) + boost::size(vals2) + boost::size(vals3)
+ n == boost::size(mat[0]) + boost::size(mat[1]) + boost::size(mat[2])
             );
                 for(flat_it_ i = b; i!=e; i++, j++){
+ typedef flat_it_::difference_type diff_;
                 val_ val = *i;
- BOOST_ASSERT(val = j);
- BOOST_ASSERT(std::distance(b,e)==n-j);
+ BOOST_ASSERT(val == j+1);
+ // diff_ d = std::distance(b,e);
+ //BOOST_ASSERT(std::distance(b,e)==n-j); //not required for single pass
             }
     }
+/*
         {
             typedef boost::range_iterator<const mat_>::type it_mat_;
                 typedef flatten_iterator<it_mat_> flat_it_;
@@ -71,6 +70,6 @@
                            BOOST_ASSERT(std::distance(b,e)==n-j);
             }
     }
-
- out << "<-" << std::endl;
+*/
+ os << "<-" << std::endl;
 }
\ No newline at end of file

Modified: sandbox/statistics/iterator/libs/iterator/example/flatten_iterator.h
==============================================================================
--- sandbox/statistics/iterator/libs/iterator/example/flatten_iterator.h (original)
+++ sandbox/statistics/iterator/libs/iterator/example/flatten_iterator.h 2010-01-27 16:36:59 EST (Wed, 27 Jan 2010)
@@ -1,9 +1,9 @@
 ///////////////////////////////////////////////////////////////////////////////
-// example::iterator::range_cycle.h //
+// example::iterator::flatten_iterator.h //
 // //
 ///////////////////////////////////////////////////////////////////////////////
-#ifndef LIBS_ITERATOR_EXAMPLE_CYCLE_ITERATOR_ER_2009
-#define LIBS_ITERATOR_EXAMPLE_CYCLE_ITERATOR_ER_2009
+#ifndef LIBS_ITERATOR_EXAMPLE_FLATTEN_ITERATOR_ER_2010
+#define LIBS_ITERATOR_EXAMPLE_FLATTEN_ITERATOR_ER_2010
 #include <ostream>
 
 void example_flatten_iterator(std::ostream& os);

Modified: sandbox/statistics/iterator/libs/iterator/src/main.cpp
==============================================================================
--- sandbox/statistics/iterator/libs/iterator/src/main.cpp (original)
+++ sandbox/statistics/iterator/libs/iterator/src/main.cpp 2010-01-27 16:36:59 EST (Wed, 27 Jan 2010)
@@ -1,11 +1,13 @@
 #include <iostream>
-#include <libs/iterator/example/range_cycle.h>
-#include <libs/iterator/example/cycle_iter.h>
+//#include <libs/iterator/example/range_cycle.h>
+//#include <libs/iterator/example/cycle_iter.h>
+#include <libs/iterator/example/flatten_iterator.h>
 
 int main () {
 
     //example_range_cycle(std::cout);
     //example_iter(std::cout);
+ example_flatten_iterator(std::cout);
     
     return 0;
 }


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