From 90dfc3f68c35fdd2782ffcd6019c370d2cc4aab0 Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Fri, 7 May 2021 20:01:20 -0700 Subject: [PATCH] use range-based for loops to abbreviate some iteration over block collections --- lib/vpsc/solve_VPSC.cpp | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/lib/vpsc/solve_VPSC.cpp b/lib/vpsc/solve_VPSC.cpp index 184150529..30d8d0c01 100644 --- a/lib/vpsc/solve_VPSC.cpp +++ b/lib/vpsc/solve_VPSC.cpp @@ -57,8 +57,7 @@ VPSC::~VPSC() { void VPSC::printBlocks() { if (RECTANGLE_OVERLAP_LOGGING) { ofstream f(LOGFILE,ios::app); - for(set::iterator i=bs->begin();i!=bs->end();i++) { - Block *b=*i; + for(Block *b : *bs) { f<<" "<<*b<<"\n"; } for(unsigned i=0;i::const_iterator i=bs->begin();i!=bs->end();i++) { - Block *b=*i; + for(Block *b : *bs) { b->setUpInConstraints(); b->setUpOutConstraints(); } - for(set::const_iterator i=bs->begin();i!=bs->end();i++) { - Block *b=*i; + for(Block *b : *bs) { Constraint *c=b->findMinLM(); if(c!=nullptr && c->lm<0) { if (RECTANGLE_OVERLAP_LOGGING) { @@ -221,8 +218,7 @@ void IncVPSC::moveBlocks() { ofstream f(LOGFILE,ios::app); f<<"moveBlocks()...\n"; } - for(set::const_iterator i(bs->begin());i!=bs->end();i++) { - Block *b = *i; + for(Block *b : *bs) { b->wposn = b->desiredWeightedPosition(); b->posn = b->wposn / b->weight; } @@ -235,8 +231,7 @@ void IncVPSC::splitBlocks() { moveBlocks(); splitCnt=0; // Split each block if necessary on min LM - for(set::const_iterator i(bs->begin());i!=bs->end();i++) { - Block* b = *i; + for(Block *b : *bs) { Constraint* v=b->findMinLM(); if(v!=nullptr && v->lm < -0.0000001) { if (RECTANGLE_OVERLAP_LOGGING) { @@ -363,14 +358,12 @@ bool VPSC::constraintGraphIsCyclic(const unsigned n, Variable *vs[]) { bool VPSC::blockGraphIsCyclic() { map bmap; vector graph; - for(set::const_iterator i=bs->begin();i!=bs->end();i++) { - Block *b=*i; + for(Block *b : *bs) { node *u=new node; graph.push_back(u); bmap[b]=u; } - for(set::const_iterator i=bs->begin();i!=bs->end();i++) { - Block *b=*i; + for(Block *b : *bs) { b->setUpInConstraints(); Constraint *c=b->findMinInConstraint(); while(c!=nullptr) { -- 2.50.1