Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r59333 - in sandbox/statistics/iterator: boost/iterator libs/iterator/example
From: erwann.rogard_at_[hidden]
Date: 2010-01-28 15:03:36


Author: e_r
Date: 2010-01-28 15:03:36 EST (Thu, 28 Jan 2010)
New Revision: 59333
URL: http://svn.boost.org/trac/boost/changeset/59333

Log:
m
Text files modified:
   sandbox/statistics/iterator/boost/iterator/flatten_iterator.hpp | 33 ++++++++++++++++++++-------------
   sandbox/statistics/iterator/libs/iterator/example/flatten_iterator.cpp | 24 +++---------------------
   2 files changed, 23 insertions(+), 34 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-28 15:03:36 EST (Thu, 28 Jan 2010)
@@ -67,12 +67,13 @@
                       , D
> super_;
 
- flatten_iterator();
-
- public:
+ public:
+
                 typedef typename super_::difference_type diff_;
                 typedef typename super_::reference ref_;
                         
+ flatten_iterator(){}
+
         explicit flatten_iterator(It b,It e):super_(),b_(b),e_(e){
                 this->update();
         }
@@ -115,24 +116,30 @@
                 }
                 }
         
- //Not needed given category_traversal
         void decrement(){
+ // For now
                         throw std::runtime_error(
                                 "flatten_iterator::decrement() not allowed"
             );
         }
         
                 void advance(diff_ n){
- // Needs checking
-
- diff_ k = std::distance(this->b_,this->e_);
- if(n<k){
- this->nb_ += boost::next(this->nb_,n);
+ if(n>0){
+ BOOST_ASSERT(!this->is_end());
+ diff_ k = std::distance(this->nb_,this->ne_);
+ if(n<k){
+ this->nb_ = boost::next(this->nb_,n);
+ }else{
+ ++this->b_;
+ this->update();
+ return this->advance(n-k);
+ }
             }else{
- diff_ nk = std::distance(this->nb_,this->ne_);
- ++this->b_;
- this->update();
- return this->advance(n-nk);
+ if(n!=0){
+ throw std::runtime_error(
+ "flatten_iterator::advance(n<0) not allowed"
+ );
+ }
             }
         }
 

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-28 15:03:36 EST (Thu, 28 Jan 2010)
@@ -49,30 +49,12 @@
                            BOOST_ASSERT(val == j+1);
             diff_ d = std::distance(i,e);
                            BOOST_ASSERT(d==n-j);
+ flat_it_ ii = b;
+ std::advance(ii,j);
+ BOOST_ASSERT(ii==i);
             }
 
     }
-/*
- {
- typedef boost::range_iterator<const mat_>::type it_mat_;
- typedef flatten_iterator<it_mat_> flat_it_;
-
- const mat_& cmat = mat;
-
- flat_it_ b = make_flatten_iterator(boost::begin(cmat),boost::end(cmat));
- flat_it_ e = make_flatten_iterator(boost::end(cmat),boost::end(cmat));
 
- int j = 0;
- int n = std::distance(b,e);
- BOOST_ASSERT(
- n == boost::size(vals1) + boost::size(vals2) + boost::size(vals3)
- );
- for(flat_it_ i = b; i!=e; i++, j++){
- val_ val = *i;
- BOOST_ASSERT(val = j);
- BOOST_ASSERT(std::distance(b,e)==n-j);
- }
- }
-*/
     os << "<-" << std::endl;
 }
\ 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