Esempio n. 1
1
 public ListNode partition(ListNode head, int x) {
   ListNode headOfHead = new ListNode(-1);
   headOfHead.next = head;
   ListNode p = headOfHead;
   while (p.next != null) {
     p = p.next;
     // CUT begin
     debug(p.val);
     // CUT end
   }
   ListNode tail = new ListNode(-1);
   p.next = tail;
   p = headOfHead;
   ListNode q = tail;
   while (p.next != tail) {
     if (p.next.val < x) {
       p = p.next;
     } else {
       q.next = p.next;
       q = q.next;
       p.next = p.next.next;
       q.next = null;
     }
   }
   p.next = tail.next;
   return headOfHead.next;
 }
Esempio n. 2
1
 @Override
 public void go() {
   // TODO Auto-generated method stub
   debug(tank.getp(p));
   tank.g(time);
   res[id] = tank.getp(p).h;
   count++;
 }
Esempio n. 3
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;
 }