reorder method

void reorder(
  1. int hole
)

Internal method to percolate down in the heap.

@param hole the index at which the percolate begins.

Implementation

void reorder(int hole) {
  int child;
  Object tmp = _items[hole];

  for (; hole * 2 <= _size; hole = child) {
    child = hole * 2;
    if (child != _size &&
        (_items[child + 1] as Comparable).compareTo(_items[child]) < 0) {
      child++;
    }
    if ((_items[child] as Comparable).compareTo(tmp) < 0)
      _items.insert(hole, _items[child]);
    else
      break;
  }
  _items.insert(hole, tmp);
}