示例#1
0
 /**
  * Rearrange the subarray A[p..r] in place.
  *
  * @param A the array to rearrange
  * @param p the beginning index
  * @param r the ending index
  * @param t the Table to swap rows for
  * @return the partition point
  */
 private int partition(long[] A, int p, int r, MutableTable t) {
   long x = A[p];
   boolean xMissing = this.isValueMissing(p);
   int i = p - 1;
   int j = r + 1;
   while (true) {
     if (xMissing) {
       j--;
       do {
         i++;
       } while (!this.isValueMissing(i));
     } else {
       do {
         j--;
       } while (this.isValueMissing(j) || (A[j] > x));
       do {
         i++;
       } while (!this.isValueMissing(i) && (A[i] < x));
     }
     if (i < j) {
       if (t == null) this.swapRows(i, j);
       else t.swapRows(i, j);
     } else return j;
   }
 }