public static final void removeMin(long[] heapKeys, double[] heapValues, int heapSize) {
    heapValues[0] = heapValues[heapSize - 1];
    heapKeys[0] = heapKeys[heapSize - 1];

    int curIndex = 0;
    int leftIndex, rightIndex, minIndex;
    boolean done = false;
    while (!done) {
      done = true;
      leftIndex = 1 + (curIndex * 2);
      rightIndex = leftIndex + 1;

      minIndex = -1;
      if (rightIndex < heapSize) {
        minIndex = heapValues[leftIndex] <= heapValues[rightIndex] ? leftIndex : rightIndex;
      } else if (leftIndex < heapSize) {
        minIndex = leftIndex;
      }

      if (minIndex != -1 && heapValues[minIndex] < heapValues[curIndex]) {
        swap(heapKeys, heapValues, curIndex, minIndex);
        done = false;
        curIndex = minIndex;
      }
    }
  }
public static final void removeMin ( long [ ] heapKeys , double [ ] heapValues , int heapSize ) { heapValues [ 0 ] = heapValues [ heapSize - 1 ] ; heapKeys [ 0 ] = heapKeys [ heapSize - 1 ] ; int curIndex = 0 ; int leftIndex , rightIndex , minIndex ; boolean done = false ; while ( ! done ) { done = true ; leftIndex = 1 + ( curIndex * 2 ) ; rightIndex = leftIndex + 1 ; minIndex = - 1 ; if ( rightIndex < heapSize ) { minIndex = heapValues [ leftIndex ] <= heapValues [ rightIndex ] ? leftIndex : rightIndex ; } else if ( leftIndex < heapSize ) { minIndex = leftIndex ; } if ( minIndex != - 1 && heapValues [ minIndex ] < heapValues [ curIndex ] ) { swap ( heapKeys , heapValues , curIndex , minIndex ) ; done = false ; curIndex = minIndex ; } } }
Removes the smallest key/value pair from the heap represented by
{@code heapKeys} and {@code heapValues}. After calling this method, the
size of the heap shrinks by 1.

@param heapKeys
@param heapValues
@param heapSize