protected int partition(double[] array,int[] index,int l,int r,final int indexStart){
  double pivot=array[(l + r) / 2];
  int help;
  while (l < r) {
    while ((array[l] < pivot) && (l < r)) {
      l++;
    }
    while ((array[r] > pivot) && (l < r)) {
      r--;
    }
    if (l < r) {
      help=index[indexStart + l];
      index[indexStart + l]=index[indexStart + r];
      index[indexStart + r]=help;
      l++;
      r--;
    }
  }
  if ((l == r) && (array[r] > pivot)) {
    r--;
  }
  return r;
}

protected int partition ( double [ ] array , int [ ] index , int l , int r , final int indexStart ) { double pivot = array [ ( l + r ) / 2 ] ; int help ; while ( l < r ) { while ( ( array [ l ] < pivot ) && ( l < r ) ) { l ++ ; } while ( ( array [ r ] > pivot ) && ( l < r ) ) { r -- ; } if ( l < r ) { help = index [ indexStart + l ] ; index [ indexStart + l ] = index [ indexStart + r ] ; index [ indexStart + r ] = help ; l ++ ; r -- ; } } if ( ( l == r ) && ( array [ r ] > pivot ) ) { r -- ; } return r ; }
partitions the instances around a pivot . used by quicksort and kthsmallestvalue .
