]> granicus.if.org Git - graphviz/commitdiff
remove use of std::endl in VPSC
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 7 Nov 2020 21:27:58 +0000 (13:27 -0800)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 14 Nov 2020 02:33:45 +0000 (18:33 -0800)
Use of std::endl is generally considered an anti-pattern these days.

lib/vpsc/block.cpp
lib/vpsc/blocks.cpp
lib/vpsc/csolve_VPSC.cpp
lib/vpsc/remove_rectangle_overlap.cpp
lib/vpsc/solve_VPSC.cpp

index cb1dfae996aed6fa796efb9a59aad605c791914e..a6537cc8d84dc3b4e3a8973e052ccda51e20e7ee 100644 (file)
@@ -24,7 +24,6 @@
 #include <fstream>
 using std::ios;
 using std::ofstream;
-using std::endl;
 using std::vector;
 
 #ifndef RECTANGLE_OVERLAP_LOGGING
@@ -90,7 +89,7 @@ void Block::setUpConstraintHeap(PairingHeap<Constraint*>* &h,bool in) {
 void Block::merge(Block* b, Constraint* c) {
        if (RECTANGLE_OVERLAP_LOGGING) {
                ofstream f(LOGFILE,ios::app);
-               f<<"  merging on: "<<*c<<",c->left->offset="<<c->left->offset<<",c->right->offset="<<c->right->offset<<endl;
+               f<<"  merging on: "<<*c<<",c->left->offset="<<c->left->offset<<",c->right->offset="<<c->right->offset<<"\n";
        }
        double dist = c->right->offset - c->left->offset - c->gap;
        Block *l=c->left->block;
@@ -102,7 +101,7 @@ void Block::merge(Block* b, Constraint* c) {
        }
        if (RECTANGLE_OVERLAP_LOGGING) {
                ofstream f(LOGFILE,ios::app);
-               f<<"  merged block="<<(b->deleted?*this:*b)<<endl;
+               f<<"  merged block="<<(b->deleted?*this:*b)<<"\n";
        }
 }
 /**
@@ -115,7 +114,7 @@ void Block::merge(Block* b, Constraint* c) {
 void Block::merge(Block *b, Constraint *c, double dist) {
        if (RECTANGLE_OVERLAP_LOGGING) {
                ofstream f(LOGFILE,ios::app);
-               f<<"    merging: "<<*b<<"dist="<<dist<<endl;
+               f<<"    merging: "<<*b<<"dist="<<dist<<"\n";
        }
        c->active=true;
        wposn+=b->wposn-dist*b->weight;
@@ -133,7 +132,7 @@ void Block::merge(Block *b, Constraint *c, double dist) {
 void Block::mergeIn(Block *b) {
        if (RECTANGLE_OVERLAP_LOGGING) {
                ofstream f(LOGFILE,ios::app);
-               f<<"  merging constraint heaps... "<<endl;
+               f<<"  merging constraint heaps... \n";
        }
        // We check the top of the heaps to remove possible internal constraints
        findMinInConstraint();
@@ -141,7 +140,7 @@ void Block::mergeIn(Block *b) {
        in->merge(b->in);
        if (RECTANGLE_OVERLAP_LOGGING) {
                ofstream f(LOGFILE,ios::app);
-               f<<"  merged heap: "<<*in<<endl;
+               f<<"  merged heap: "<<*in<<"\n";
        }
 }
 void Block::mergeOut(Block *b) {       
@@ -160,20 +159,20 @@ Constraint *Block::findMinInConstraint() {
                if (RECTANGLE_OVERLAP_LOGGING) {
                        ofstream f(LOGFILE,ios::app);
                        f<<"  checking constraint ... "<<*v;
-                       f<<"    timestamps: left="<<lb->timeStamp<<" right="<<rb->timeStamp<<" constraint="<<v->timeStamp<<endl;
+                       f<<"    timestamps: left="<<lb->timeStamp<<" right="<<rb->timeStamp<<" constraint="<<v->timeStamp<<"\n";
                }
                if(lb == rb) {
                        // constraint has been merged into the same block
                        if(RECTANGLE_OVERLAP_LOGGING && v->slack()<0) {
                                ofstream f(LOGFILE,ios::app);
-                               f<<"  violated internal constraint found! "<<*v<<endl;
-                               f<<"     lb="<<*lb<<endl;
-                               f<<"     rb="<<*rb<<endl;
+                               f<<"  violated internal constraint found! "<<*v<<"\n";
+                               f<<"     lb="<<*lb<<"\n";
+                               f<<"     rb="<<*rb<<"\n";
                        }
                        in->deleteMin();
                        if (RECTANGLE_OVERLAP_LOGGING) {
                                ofstream f(LOGFILE,ios::app);
-                               f<<" ... skipping internal constraint"<<endl;
+                               f<<" ... skipping internal constraint\n";
                        }
                } else if(v->timeStamp < lb->timeStamp) {
                        // block at other end of constraint has been moved since this
@@ -181,7 +180,7 @@ Constraint *Block::findMinInConstraint() {
                        outOfDate.push_back(v);
                        if (RECTANGLE_OVERLAP_LOGGING) {
                                ofstream f(LOGFILE,ios::app);
-                               f<<"    reinserting out of date (reinsert later)"<<endl;
+                               f<<"    reinserting out of date (reinsert later)\n";
                        }
                } else {
                        break;
@@ -213,8 +212,8 @@ void Block::deleteMinInConstraint() {
        in->deleteMin();
        if (RECTANGLE_OVERLAP_LOGGING) {
                ofstream f(LOGFILE,ios::app);
-               f<<"deleteMinInConstraint... "<<endl;
-               f<<"  result: "<<*in<<endl;
+               f<<"deleteMinInConstraint... \n";
+               f<<"  result: "<<*in<<"\n";
        }
 }
 void Block::deleteMinOutConstraint() {
@@ -363,12 +362,12 @@ void Block::populateSplitBlock(Block *b, Variable *v, Variable *u) {
 Constraint* Block::splitBetween(Variable* vl, Variable* vr, Block* &lb, Block* &rb) {
        if (RECTANGLE_OVERLAP_LOGGING) {
                ofstream f(LOGFILE,ios::app);
-               f<<"  need to split between: "<<*vl<<" and "<<*vr<<endl;
+               f<<"  need to split between: "<<*vl<<" and "<<*vr<<"\n";
        }
        Constraint *c=findMinLMBetween(vl, vr);
        if (RECTANGLE_OVERLAP_LOGGING) {
                ofstream f(LOGFILE,ios::app);
-               f<<"  going to split on: "<<*c<<endl;
+               f<<"  going to split on: "<<*c<<"\n";
        }
        split(lb,rb,c);
        deleted = true;
index 09f52db4d8c01f2d27ef83388ef50b67ee26684d..ac210e54f8732a9ebcc1f00a9ced9719b6160e56 100644 (file)
@@ -25,7 +25,6 @@
 #include <fstream>
 using std::ios;
 using std::ofstream;
-using std::endl;
 using std::set;
 using std::vector;
 using std::iterator;
@@ -82,7 +81,7 @@ void Blocks::dfsVisit(Variable *v, list<Variable*> *order) {
        }       
        if (RECTANGLE_OVERLAP_LOGGING) {
                ofstream f(LOGFILE,ios::app);
-               f<<"  order="<<*v<<endl;
+               f<<"  order="<<*v<<"\n";
        }
        order->push_front(v);
 }
@@ -93,7 +92,7 @@ void Blocks::dfsVisit(Variable *v, list<Variable*> *order) {
 void Blocks::mergeLeft(Block *r) {     
        if (RECTANGLE_OVERLAP_LOGGING) {
                ofstream f(LOGFILE,ios::app);
-               f<<"mergeLeft called on "<<*r<<endl;
+               f<<"mergeLeft called on "<<*r<<"\n";
        }
        r->timeStamp=++blockTimeCtr;
        r->setUpInConstraints();
@@ -101,7 +100,7 @@ void Blocks::mergeLeft(Block *r) {
        while (c != NULL && c->slack()<0) {
                if (RECTANGLE_OVERLAP_LOGGING) {
                        ofstream f(LOGFILE,ios::app);
-                       f<<"mergeLeft on constraint: "<<*c<<endl;
+                       f<<"mergeLeft on constraint: "<<*c<<"\n";
                }
                r->deleteMinInConstraint();
                Block *l = c->left->block;              
@@ -120,7 +119,7 @@ void Blocks::mergeLeft(Block *r) {
        }               
        if (RECTANGLE_OVERLAP_LOGGING) {
                ofstream f(LOGFILE,ios::app);
-               f<<"merged "<<*r<<endl;
+               f<<"merged "<<*r<<"\n";
        }
 }      
 /**
@@ -129,14 +128,14 @@ void Blocks::mergeLeft(Block *r) {
 void Blocks::mergeRight(Block *l) {    
        if (RECTANGLE_OVERLAP_LOGGING) {
                ofstream f(LOGFILE,ios::app);
-               f<<"mergeRight called on "<<*l<<endl;
+               f<<"mergeRight called on "<<*l<<"\n";
        }
        l->setUpOutConstraints();
        Constraint *c = l->findMinOutConstraint();
        while (c != NULL && c->slack()<0) {             
                if (RECTANGLE_OVERLAP_LOGGING) {
                        ofstream f(LOGFILE,ios::app);
-                       f<<"mergeRight on constraint: "<<*c<<endl;
+                       f<<"mergeRight on constraint: "<<*c<<"\n";
                }
                l->deleteMinOutConstraint();
                Block *r = c->right->block;
@@ -153,7 +152,7 @@ void Blocks::mergeRight(Block *l) {
        }       
        if (RECTANGLE_OVERLAP_LOGGING) {
                ofstream f(LOGFILE,ios::app);
-               f<<"merged "<<*l<<endl;
+               f<<"merged "<<*l<<"\n";
        }
 }
 void Blocks::removeBlock(Block *doomed) {
@@ -178,8 +177,8 @@ void Blocks::split(Block *b, Block *&l, Block *&r, Constraint *c) {
        b->split(l,r,c);
        if (RECTANGLE_OVERLAP_LOGGING) {
                ofstream f(LOGFILE,ios::app);
-               f<<"Split left: "<<*l<<endl;
-               f<<"Split right: "<<*r<<endl;
+               f<<"Split left: "<<*l<<"\n";
+               f<<"Split right: "<<*r<<"\n";
        }
        r->posn = b->posn;
        r->wposn = r->posn * r->weight;
index 0676d735338a99640aa11560f928f7d85a76e9f5..716c30dee42e1a39f650fde6f891e4bc566b05d0 100644 (file)
@@ -94,7 +94,7 @@ void satisfyVPSC(VPSC* vpsc) {
        try {
                vpsc->satisfy();
        } catch(const char *e) {
-               std::cerr << e << std::endl;
+               std::cerr << e << "\n";
                std::exit(1);
        }
 }
index ff94baef70b9a4e2201b61272874be81aa3fe38a..ca649616d4da7d91f4ea9939f83ff708442d1aa2 100644 (file)
@@ -25,7 +25,6 @@
 #include <vpsc/blocks.h>
 using std::ios;
 using std::ofstream;
-using std::endl;
 
 #ifndef RECTANGLE_OVERLAP_LOGGING
        #define RECTANGLE_OVERLAP_LOGGING 0
@@ -66,7 +65,7 @@ void removeRectangleOverlap(int n, Rectangle *rs[], double xBorder, double yBord
        VPSC vpsc_x(n,vs,m,cs);
        if (RECTANGLE_OVERLAP_LOGGING) {
                ofstream f(LOGFILE,ios::app);
-               f<<"Calling VPSC: Horizontal pass 1"<<endl;
+               f<<"Calling VPSC: Horizontal pass 1\n";
        }
        vpsc_x.solve();
        for(int i=0;i<n;i++) {
@@ -83,7 +82,7 @@ void removeRectangleOverlap(int n, Rectangle *rs[], double xBorder, double yBord
        VPSC vpsc_y(n,vs,m,cs);
        if (RECTANGLE_OVERLAP_LOGGING) {
                ofstream f(LOGFILE,ios::app);
-               f<<"Calling VPSC: Vertical pass"<<endl;
+               f<<"Calling VPSC: Vertical pass\n";
        }
        vpsc_y.solve();
        for(int i=0;i<n;i++) {
@@ -100,7 +99,7 @@ void removeRectangleOverlap(int n, Rectangle *rs[], double xBorder, double yBord
        VPSC vpsc_x2(n,vs,m,cs);
        if (RECTANGLE_OVERLAP_LOGGING) {
                ofstream f(LOGFILE,ios::app);
-               f<<"Calling VPSC: Horizontal pass 2"<<endl;
+               f<<"Calling VPSC: Horizontal pass 2\n";
        }
        vpsc_x2.solve();
        for(int i=0;i<n;i++) {
@@ -113,9 +112,9 @@ void removeRectangleOverlap(int n, Rectangle *rs[], double xBorder, double yBord
        }
        delete [] cs;
        } catch (char const *str) {
-               std::cerr<<str<<std::endl;
+               std::cerr<<str<<"\n";
                for(int i=0;i<n;i++) {
-                       std::cerr << *rs[i]<<std::endl;
+                       std::cerr << *rs[i]<<"\n";
                }
        }
 }
index 7abc9bff8ef2d503befd5c2fac3a089674f3ecd9..1ebeda7cb38dc690be72d5aa9dce9dce02851954 100644 (file)
@@ -26,7 +26,6 @@
 #include <fstream>
 using std::ios;
 using std::ofstream;
-using std::endl;
 
 using std::ostringstream;
 using std::list;
@@ -60,10 +59,10 @@ void VPSC::printBlocks() {
                ofstream f(LOGFILE,ios::app);
                for(set<Block*>::iterator i=bs->begin();i!=bs->end();i++) {
                        Block *b=*i;
-                       f<<"  "<<*b<<endl;
+                       f<<"  "<<*b<<"\n";
                }
                for(unsigned i=0;i<m;i++) {
-                       f<<"  "<<*cs[i]<<endl;
+                       f<<"  "<<*cs[i]<<"\n";
                }
        }
 }
@@ -90,7 +89,7 @@ void VPSC::satisfy() {
                if(cs[i]->slack()<-0.0000001) {
                        if (RECTANGLE_OVERLAP_LOGGING) {
                                ofstream f(LOGFILE,ios::app);
-                               f<<"Error: Unsatisfied constraint: "<<*cs[i]<<endl;
+                               f<<"Error: Unsatisfied constraint: "<<*cs[i]<<"\n";
                        }
                        //assert(cs[i]->slack()>-0.0000001);
                        throw "Unsatisfied constraint";
@@ -118,7 +117,7 @@ void VPSC::refine() {
                        if(c!=NULL && c->lm<0) {
                                if (RECTANGLE_OVERLAP_LOGGING) {
                                        ofstream f(LOGFILE,ios::app);
-                                       f<<"Split on constraint: "<<*c<<endl;
+                                       f<<"Split on constraint: "<<*c<<"\n";
                                }
                                // Split on c
                                Block *l=NULL, *r=NULL;
@@ -151,7 +150,7 @@ void VPSC::solve() {
 void IncVPSC::solve() {
        if (RECTANGLE_OVERLAP_LOGGING) {
                ofstream f(LOGFILE,ios::app);
-               f<<"solve_inc()..."<<endl;
+               f<<"solve_inc()...\n";
        }
        double lastcost,cost = bs->cost();
        do {
@@ -161,7 +160,7 @@ void IncVPSC::solve() {
                cost = bs->cost();
                if (RECTANGLE_OVERLAP_LOGGING) {
                        ofstream f(LOGFILE,ios::app);
-                       f<<"  cost="<<cost<<endl;
+                       f<<"  cost="<<cost<<"\n";
                }
        } while(fabs(lastcost-cost)>0.0001);
 }
@@ -181,7 +180,7 @@ void IncVPSC::solve() {
 void IncVPSC::satisfy() {
        if (RECTANGLE_OVERLAP_LOGGING) {
                ofstream f(LOGFILE,ios::app);
-               f<<"satisfy_inc()..."<<endl;
+               f<<"satisfy_inc()...\n";
        }
        splitBlocks();
        long splitCtr = 0;
@@ -203,7 +202,7 @@ void IncVPSC::satisfy() {
        }
        if (RECTANGLE_OVERLAP_LOGGING) {
                ofstream f(LOGFILE,ios::app);
-               f<<"  finished merges."<<endl;
+               f<<"  finished merges.\n";
        }
        bs->cleanup();
        for(unsigned i=0;i<m;i++) {
@@ -217,14 +216,14 @@ void IncVPSC::satisfy() {
        }
        if (RECTANGLE_OVERLAP_LOGGING) {
                ofstream f(LOGFILE,ios::app);
-               f<<"  finished cleanup."<<endl;
+               f<<"  finished cleanup.\n";
                printBlocks();
        }
 }
 void IncVPSC::moveBlocks() {
        if (RECTANGLE_OVERLAP_LOGGING) {
                ofstream f(LOGFILE,ios::app);
-               f<<"moveBlocks()..."<<endl;
+               f<<"moveBlocks()...\n";
        }
        for(set<Block*>::const_iterator i(bs->begin());i!=bs->end();i++) {
                Block *b = *i;
@@ -233,7 +232,7 @@ void IncVPSC::moveBlocks() {
        }
        if (RECTANGLE_OVERLAP_LOGGING) {
                ofstream f(LOGFILE,ios::app);
-               f<<"  moved blocks."<<endl;
+               f<<"  moved blocks.\n";
        }
 }
 void IncVPSC::splitBlocks() {
@@ -246,7 +245,7 @@ void IncVPSC::splitBlocks() {
                if(v!=NULL && v->lm < -0.0000001) {
                        if (RECTANGLE_OVERLAP_LOGGING) {
                                ofstream f(LOGFILE,ios::app);
-                               f<<"    found split point: "<<*v<<" lm="<<v->lm<<endl;
+                               f<<"    found split point: "<<*v<<" lm="<<v->lm<<"\n";
                        }
                        splitCnt++;
                        Block *b = v->left->block, *l=NULL, *r=NULL;
@@ -262,13 +261,13 @@ void IncVPSC::splitBlocks() {
                        inactive.push_back(v);
                        if (RECTANGLE_OVERLAP_LOGGING) {
                                ofstream f(LOGFILE,ios::app);
-                               f<<"  new blocks: "<<*l<<" and "<<*r<<endl;
+                               f<<"  new blocks: "<<*l<<" and "<<*r<<"\n";
                        }
                }
        }
        if (RECTANGLE_OVERLAP_LOGGING) {
                ofstream f(LOGFILE,ios::app);
-               f<<"  finished splits."<<endl;
+               f<<"  finished splits.\n";
        }
        bs->cleanup();
 }
@@ -281,7 +280,7 @@ double IncVPSC::mostViolated(ConstraintList &l, Constraint* &v) {
        double minSlack = DBL_MAX;
        if (RECTANGLE_OVERLAP_LOGGING) {
                ofstream f(LOGFILE,ios::app);
-               f<<"Looking for most violated..."<<endl;
+               f<<"Looking for most violated...\n";
        }
        ConstraintList::iterator end = l.end();
        ConstraintList::iterator deletePoint = end;
@@ -305,7 +304,7 @@ double IncVPSC::mostViolated(ConstraintList &l, Constraint* &v) {
        }
        if (RECTANGLE_OVERLAP_LOGGING) {
                ofstream f(LOGFILE,ios::app);
-               f<<"  most violated is: "<<*v<<endl;
+               f<<"  most violated is: "<<*v<<"\n";
        }
        return minSlack;
 }