Example #1
1
 boolean go(double ntime, Box box) {
   debug("go");
   g(ntime);
   for (int i = 0; i < bs.size() - 1; i++)
     if (bs.get(i) == box) {
       Box nb = box.h1 <= box.h2 ? bs.get(i - 1) : bs.get(i + 1);
       if (eq(nb.h, box.h)) {
         Box nbox = box.combine(nb);
         bs.remove(box);
         bs.add(i, nbox);
         bs.remove(nb);
       } else {
         nb.f += box.f;
         box.f = 0;
       }
       return true;
     }
   return false;
 }
Example #2
0
 Box combine(Box b) {
   if (b2 != b.b1) return b.combine(this);
   return new Box(b1, b.b2, h1, b.h2, f + b.f, h);
 }