protected void heapify(int position)
  {
//    if (tc.isEntryEnabled())
//      SibTr.entry(tc, "heapify", new Integer(position));

    // Heapify the remaining heap
    int i = -1;
    int l;
    int r;
    int smallest = position;

    // Heapify routine from CMR.
    // This was done without recursion.
    while (smallest != i)
    {
      i = smallest;
      l = left(i);
      r = right(i);
      if ((l < size) && (elements[l].priority < elements[i].priority))
        smallest = l;
      else smallest = i;
      if ((r < size) && (elements[r].priority < elements[smallest].priority))
        smallest = r;
      if (smallest != i)
      {
        PriorityQueueNode tmp = elements[smallest];
        setElement(elements[i], smallest);
        setElement(tmp, i);
      }
    }

//    if (tc.isEntryEnabled())
//      SibTr.exit(tc, "heapify");
  }
protected void heapify ( int position ) { int i = - 1 ; int l ; int r ; int smallest = position ; while ( smallest != i ) { i = smallest ; l = left ( i ) ; r = right ( i ) ; if ( ( l < size ) && ( elements [ l ] . priority < elements [ i ] . priority ) ) smallest = l ; else smallest = i ; if ( ( r < size ) && ( elements [ r ] . priority < elements [ smallest ] . priority ) ) smallest = r ; if ( smallest != i ) { PriorityQueueNode tmp = elements [ smallest ] ; setElement ( elements [ i ] , smallest ) ; setElement ( tmp , i ) ; } } }
Reheap the queue.

@param position The position from which to start reheaping.