#define RECTANGLE_OVERLAP_LOGGING 0
#endif
-typedef vector<Constraint*>::iterator Cit;
-
void Block::addVariable(Variable *v) {
v->block=this;
vars.push_back(v);
new PairingHeap<Constraint*>(&compareConstraints));
for (Variable *v : vars) {
vector<Constraint*> *cs=in?&(v->in):&(v->out);
- for (vector<Constraint*>::iterator j=cs->begin();j!=cs->end();j++) {
- Constraint *c=*j;
+ for (Constraint *c : *cs) {
c->timeStamp=blockTimeCtr;
if ((c->left->block != this && in) || (c->right->block != this && !in)) {
h->insert(c);
break;
}
}
- for(vector<Constraint*>::iterator i=outOfDate.begin();i!=outOfDate.end();i++) {
- v=*i;
+ for (Constraint *v : outOfDate) {
v->timeStamp=blockTimeCtr;
in->insert(v);
}
// in min_lm
double Block::compute_dfdv(Variable *v, Variable *u, Constraint *&min_lm) {
double dfdv=v->weight*(v->position() - v->desiredPosition);
- for(vector<Constraint*>::iterator it=v->out.begin();it!=v->out.end();it++) {
- Constraint *c=*it;
+ for (Constraint *c : v->out) {
if(canFollowRight(c,u)) {
dfdv+=c->lm=compute_dfdv(c->right,v,min_lm);
if(min_lm==nullptr||c->lm<min_lm->lm) min_lm=c;
}
}
- for(vector<Constraint*>::iterator it=v->in.begin();it!=v->in.end();it++) {
- Constraint *c=*it;
+ for (Constraint *c : v->in) {
if(canFollowLeft(c,u)) {
dfdv-=c->lm=-compute_dfdv(c->left,v,min_lm);
if(min_lm==nullptr||c->lm<min_lm->lm) min_lm=c;
Direction dir = NONE, bool changedDirection = false) {
double dfdv=v->weight*(v->position() - v->desiredPosition);
Constraint *m=nullptr;
- for(Cit it(v->in.begin());it!=v->in.end();it++) {
- Constraint *c=*it;
+ for (Constraint *c : v->in) {
if(canFollowLeft(c,u)) {
if(dir==RIGHT) {
changedDirection = true;
m = p.second;
}
}
- for(Cit it(v->out.begin());it!=v->out.end();it++) {
- Constraint *c=*it;
+ for (Constraint *c : v->out) {
if(canFollowRight(c,u)) {
if(dir==LEFT) {
changedDirection = true;
// traversing active constraint tree starting from v,
// not back tracking over u
void Block::reset_active_lm(Variable *v, Variable *u) {
- for(vector<Constraint*>::iterator it=v->out.begin();it!=v->out.end();it++) {
- Constraint *c=*it;
+ for (Constraint *c : v->out) {
if(canFollowRight(c,u)) {
c->lm=0;
reset_active_lm(c->right,v);
}
}
- for(vector<Constraint*>::iterator it=v->in.begin();it!=v->in.end();it++) {
- Constraint *c=*it;
+ for (Constraint *c : v->in) {
if(canFollowLeft(c,u)) {
c->lm=0;
reset_active_lm(c->left,v);
// visited. Starts from variable v and does not backtrack over variable u.
void Block::populateSplitBlock(Block *b, Variable *v, Variable *u) {
b->addVariable(v);
- for (vector<Constraint*>::iterator c=v->in.begin();c!=v->in.end();c++) {
- if (canFollowLeft(*c,u))
- populateSplitBlock(b, (*c)->left, v);
+ for (Constraint *c : v->in) {
+ if (canFollowLeft(c,u))
+ populateSplitBlock(b, c->left, v);
}
- for (vector<Constraint*>::iterator c=v->out.begin();c!=v->out.end();c++) {
- if (canFollowRight(*c,u))
- populateSplitBlock(b, (*c)->right, v);
+ for (Constraint *c : v->out) {
+ if (canFollowRight(c,u))
+ populateSplitBlock(b, c->right, v);
}
}
/**