private static void adjust(Object[] array,Comparator c,int lower,int upper){
  int j, k;
  Object temp;
  j=lower;
  k=lower * 2;
  while (k <= upper) {
    if ((k < upper) && (c.compare(array[k - 1],array[k]) < 0)) {
      k+=1;
    }
    if (c.compare(array[j - 1],array[k - 1]) < 0) {
      temp=array[j - 1];
      array[j - 1]=array[k - 1];
      array[k - 1]=temp;
    }
    j=k;
    k*=2;
  }
}

private static void adjust ( Object [ ] array , Comparator c , int lower , int upper ) { int j , k ; Object temp ; j = lower ; k = lower * 2 ; while ( k <= upper ) { if ( ( k < upper ) && ( c . compare ( array [ k - 1 ] , array [ k ] ) < 0 ) ) { k += 1 ; } if ( c . compare ( array [ j - 1 ] , array [ k - 1 ] ) < 0 ) { temp = array [ j - 1 ] ; array [ j - 1 ] = array [ k - 1 ] ; array [ k - 1 ] = temp ; } j = k ; k *= 2 ; } }
assumes that array [ lower + 1 ] through to array [ upper ] is already in heap form and then puts array [ lower ] to array [ upper ] in heap form .
