Use of std::endl is generally considered an anti-pattern these days.
#include <fstream>
using std::ios;
using std::ofstream;
-using std::endl;
using std::vector;
#ifndef RECTANGLE_OVERLAP_LOGGING
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;
}
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";
}
}
/**
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;
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();
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) {
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
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;
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() {
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;
#include <fstream>
using std::ios;
using std::ofstream;
-using std::endl;
using std::set;
using std::vector;
using std::iterator;
}
if (RECTANGLE_OVERLAP_LOGGING) {
ofstream f(LOGFILE,ios::app);
- f<<" order="<<*v<<endl;
+ f<<" order="<<*v<<"\n";
}
order->push_front(v);
}
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();
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;
}
if (RECTANGLE_OVERLAP_LOGGING) {
ofstream f(LOGFILE,ios::app);
- f<<"merged "<<*r<<endl;
+ f<<"merged "<<*r<<"\n";
}
}
/**
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;
}
if (RECTANGLE_OVERLAP_LOGGING) {
ofstream f(LOGFILE,ios::app);
- f<<"merged "<<*l<<endl;
+ f<<"merged "<<*l<<"\n";
}
}
void Blocks::removeBlock(Block *doomed) {
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;
try {
vpsc->satisfy();
} catch(const char *e) {
- std::cerr << e << std::endl;
+ std::cerr << e << "\n";
std::exit(1);
}
}
#include <vpsc/blocks.h>
using std::ios;
using std::ofstream;
-using std::endl;
#ifndef RECTANGLE_OVERLAP_LOGGING
#define RECTANGLE_OVERLAP_LOGGING 0
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++) {
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++) {
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++) {
}
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";
}
}
}
#include <fstream>
using std::ios;
using std::ofstream;
-using std::endl;
using std::ostringstream;
using std::list;
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";
}
}
}
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";
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;
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 {
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);
}
void IncVPSC::satisfy() {
if (RECTANGLE_OVERLAP_LOGGING) {
ofstream f(LOGFILE,ios::app);
- f<<"satisfy_inc()..."<<endl;
+ f<<"satisfy_inc()...\n";
}
splitBlocks();
long splitCtr = 0;
}
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++) {
}
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;
}
if (RECTANGLE_OVERLAP_LOGGING) {
ofstream f(LOGFILE,ios::app);
- f<<" moved blocks."<<endl;
+ f<<" moved blocks.\n";
}
}
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;
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();
}
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;
}
if (RECTANGLE_OVERLAP_LOGGING) {
ofstream f(LOGFILE,ios::app);
- f<<" most violated is: "<<*v<<endl;
+ f<<" most violated is: "<<*v<<"\n";
}
return minSlack;
}