From cfaff40a790e261f537143300880e3c16ed306c5 Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (l)" <j.wuttke@fz-juelich.de> Date: Sun, 27 Dec 2015 19:06:06 +0100 Subject: [PATCH] Repaired bug introduced in deb37dbc; now tests pass --- pub/lib/fsel.cpp | 9 ++++++--- pub/lib/loop.cpp | 15 ++++++++++++--- pub/lib/loop.hpp | 1 - 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/pub/lib/fsel.cpp b/pub/lib/fsel.cpp index db2ccfc5..23c1521c 100644 --- a/pub/lib/fsel.cpp +++ b/pub/lib/fsel.cpp @@ -9,7 +9,6 @@ #include "defs.hpp" #include <cmath> -#include <algorithm> #include "olf.hpp" #include "ptr.hpp" @@ -34,7 +33,9 @@ namespace NSel { const vector<int> selD() { vector<int> ret; - copy_if( FSel.begin(), FSel.end(), ret.begin(), [](int k){ return P2D(NOlm::mem_get(k)); } ); + for( int k: FSel ) + if( P2D(NOlm::mem_get(k)) ) + ret.push_back( k ); return ret; } @@ -42,7 +43,9 @@ namespace NSel { const vector<int> selC() { vector<int> ret; - copy_if( FSel.begin(), FSel.end(), ret.begin(), [](int k){ return P2C(NOlm::mem_get(k)); } ); + for( int k: FSel ) + if( P2C(NOlm::mem_get(k)) ) + ret.push_back( k ); return ret; } diff --git a/pub/lib/loop.cpp b/pub/lib/loop.cpp index 175d451a..4f1e172d 100644 --- a/pub/lib/loop.cpp +++ b/pub/lib/loop.cpp @@ -28,7 +28,9 @@ FileIterator::FileIterator( const vector<int>& _Sel, bool tolerate_empty ) } POlo FileIterator::get() -{ if ( !going() ) +{ + cout << "DEBUG 1\n"; + if ( iV>=Sel.size() ) return POlo(); int k=Sel[iV]; if( k<0 ) @@ -36,19 +38,26 @@ POlo FileIterator::get() if( k>=NOlm::mem_size() ) throw "FileSelection["+S(iV)+"]="+S(k)+" exceeds online memory size "+S(NOlm::mem_size()); ++iV; + cout << "DEBUG 2\n"; return NOlm::mem_get(k); } POld FileIterator::getD() { - if( POld ret = P2D(get()) ) + POlo f = get(); + if( !f ) + return POld(); + if( POld ret = P2D(f) ) return ret; throw S("BUG: non-D file found by D iterator"); } POlc FileIterator::getC() { - if( POlc ret = P2C(get()) ) + POlo f = get(); + if( !f ) + return POlc(); + if( POlc ret = P2C(f) ) return ret; throw S("BUG: non-C file found by C iterator"); } diff --git a/pub/lib/loop.hpp b/pub/lib/loop.hpp index 2d649221..a4262b5b 100644 --- a/pub/lib/loop.hpp +++ b/pub/lib/loop.hpp @@ -14,7 +14,6 @@ class FileIterator { private: int iV; vector<int> Sel; - bool going() const { return iV<Sel.size(); } public: FileIterator( const vector<int>& _Sel, bool tolerate_empty=false ); void reset() { iV = 0; } -- GitLab