From 99d1a08e7c0d417f1a2898fd4cc2463813953e18 Mon Sep 17 00:00:00 2001 From: nojhan Date: Fri, 14 Oct 2011 10:34:33 +0200 Subject: [PATCH] repairer dispatcher may be used with an unordered vector of indexes, thus we use a vector and not a set --- edo/src/edoRepairerDispatcher.h | 17 ++++++++--------- edo/test/t-dispatcher-round.cpp | 12 ++++++------ 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/edo/src/edoRepairerDispatcher.h b/edo/src/edoRepairerDispatcher.h index 96c07da5..5c4aa7d8 100644 --- a/edo/src/edoRepairerDispatcher.h +++ b/edo/src/edoRepairerDispatcher.h @@ -29,7 +29,6 @@ Authors: #define _edoRepairerDispatcher_h #include -#include #include #include "edoRepairer.h" @@ -52,28 +51,28 @@ template < typename EOT > class edoRepairerDispatcher : public edoRepairer, std::vector< - std::pair< std::set< unsigned int >, edoRepairer< EOT >* > + std::pair< std::vector< unsigned int >, edoRepairer< EOT >* > > { public: //! Empty constructor edoRepairerDispatcher() : std::vector< - std::pair< std::set< unsigned int >, edoRepairer< EOT >* > + std::pair< std::vector< unsigned int >, edoRepairer< EOT >* > >() {} //! Constructor with a single index set and repairer operator - edoRepairerDispatcher( std::set idx, edoRepairer* op ) : + edoRepairerDispatcher( std::vector idx, edoRepairer* op ) : std::vector< - std::pair< std::set< unsigned int >, edoRepairer< EOT >* > + std::pair< std::vector< unsigned int >, edoRepairer< EOT >* > >() { this->add( idx, op ); } //! Add more indexes set and their corresponding repairer operator address to the list - void add( std::set idx, edoRepairer* op ) + void add( std::vector idx, edoRepairer* op ) { assert( idx.size() > 0 ); assert( op != NULL ); @@ -90,7 +89,7 @@ public: EOT partsol; // j is an iterator that points on an uint - for( std::set< unsigned int >::iterator j = ipair->first.begin(); j != ipair->first.end(); ++j ) { + for( std::vector< unsigned int >::iterator j = ipair->first.begin(); j != ipair->first.end(); ++j ) { partsol.push_back( sol.at(*j) ); } // for j @@ -101,9 +100,9 @@ public: (*(ipair->second))( partsol ); { // copy back the repaired partial solution to sol - // browse partsol with uint k, and the idx set with an iterator (std::set is an associative tab) + // browse partsol with uint k, and the idx set with an iterator (std::vector is an associative tab) unsigned int k=0; - for( std::set< unsigned int >::iterator j = ipair->first.begin(); j != ipair->first.end(); ++j ) { + for( std::vector< unsigned int >::iterator j = ipair->first.begin(); j != ipair->first.end(); ++j ) { sol[ *j ] = partsol[ k ]; k++; } // for j diff --git a/edo/test/t-dispatcher-round.cpp b/edo/test/t-dispatcher-round.cpp index 245a2e2c..89fc1644 100644 --- a/edo/test/t-dispatcher-round.cpp +++ b/edo/test/t-dispatcher-round.cpp @@ -43,13 +43,13 @@ int main(void) edoRepairer* rep1 = new edoRepairerFloor(); edoRepairer* rep2 = new edoRepairerCeil(); - std::set indexes1; - indexes1.insert(0); - indexes1.insert(2); + std::vector indexes1; + indexes1.push_back(0); + indexes1.push_back(2); - std::set indexes2; - indexes2.insert(1); - indexes2.insert(3); + std::vector indexes2; + indexes2.push_back(1); + indexes2.push_back(3); edoRepairerDispatcher repare( indexes1, rep1 ); repare.add( indexes2, rep2 );