game-ai/src/main/java/com/jzy/game/ai/util/BinaryHeap.java
/**
     * Given an index in the heap array, percolate that key up the heap.
     *
     * @param index an index into the heap array
     */
Given an index in the heap array, percolate that key up the heap.
@param index an index into the heap array
Given an index in the heap array percolate that key up the heap . @param index an index into the heap array
public void percolateUp(int index) {
        E temp = elements[index];  
        while (index > 1) {
            if (temp.compareTo(elements[index / 2]) < 0) {
                elements[index] = elements[index / 2];
                index = index / 2;
            } else {
                break;
            }
        }
        elements[index] = temp;
    }
public void percolateUp ( int index ) { E temp = elements [ index ] ; while ( index > 1 ) { if ( temp . compareTo ( elements [ index / 2 ] ) < 0 ) { elements [ index ] = elements [ index / 2 ] ; index = index / 2 ; } else { break ; } } elements [ index ] = temp ; }
Given an index in the heap array, percolate that key up the heap.
Given an index in the heap array percolate that key up the heap .
// keep track of the item to be moved