protected boolean heapifyDownComparator(final int ipos,Object cur){
  int pos=ipos;
  final int half=size >>> 1;
  while (pos < half) {
    int min=pos;
    Object best=cur;
    final int lchild=(pos << 1) + 1;
    Object left=queue[lchild];
    if (comparator.compare(best,left) > 0) {
      min=lchild;
      best=left;
    }
    final int rchild=lchild + 1;
    if (rchild < size) {
      Object right=queue[rchild];
      if (comparator.compare(best,right) > 0) {
        min=rchild;
        best=right;
      }
    }
    if (min == pos) {
      break;
    }
    queue[pos]=best;
    pos=min;
  }
  queue[pos]=cur;
  return (pos != ipos);
}

protected boolean heapifyDownComparator ( final int ipos , Object cur ) { int pos = ipos ; final int half = size > > > 1 ; while ( pos < half ) { int min = pos ; Object best = cur ; final int lchild = ( pos << 1 ) + 1 ; Object left = queue [ lchild ] ; if ( comparator . compare ( best , left ) > 0 ) { min = lchild ; best = left ; } final int rchild = lchild + 1 ; if ( rchild < size ) { Object right = queue [ rchild ] ; if ( comparator . compare ( best , right ) > 0 ) { min = rchild ; best = right ; } } if ( min == pos ) { break ; } queue [ pos ] = best ; pos = min ; } queue [ pos ] = cur ; return ( pos != ipos ) ; }
execute a " heapify downwards " aka " siftdown " . used in deletions .
