Пример #1
0
 public void pack() {
   boolean changed;
   do {
     changed = false;
     for (Row<T> r : this) {
       changed |= r.tryInterleaveWith(r.getPrevRow());
     }
     // System.out.println();
     for (Row<T> r : this) {
       changed |= r.tryInterleaveWith(r.getNextRow());
     }
     // System.out.println();
   } while (changed);
 }
Пример #2
0
 public boolean isInterleaveableWith(Row<T> other) {
   if (other == null || other == this) {
     return false;
   } else if (other.getNextRow() != this && other.getPrevRow() != this) {
     return false;
   }
   Iterator<Cell<T>> oIt = other.iterator();
   for (Cell<T> c : this) {
     if (oIt.next().isUnpackable() && c.isUnpackable()) {
       return false;
     }
   }
   return true;
 }