game-ai/src/main/java/com/jzy/game/ai/util/BinaryHeap.java
/**
     * Given an array of Comparables, return a binary heap of those elements.
     *
     * @param data an array of data (no particular order)
     * @return a binary heap of the given data
     */
Given an array of Comparables, return a binary heap of those elements.
@param data an array of data (no particular order)
@return a binary heap of the given data
Given an array of Comparables return a binary heap of those elements . @param data an array of data ( no particular order ) @return a binary heap of the given data
public static BinaryHeap buildHeap(Comparable[] data) {
        BinaryHeap newHeap = new BinaryHeap(data.length);
        System.arraycopy(data, 0, newHeap.elements, 1, data.length);
        newHeap.size = data.length;
        for (int i = newHeap.size / 2; i > 0; i--) {
            newHeap.percolateDown(i);
        }
        return newHeap;
    }
public static BinaryHeap buildHeap ( Comparable [ ] data ) { BinaryHeap newHeap = new BinaryHeap ( data . length ) ; System . arraycopy ( data , 0 , newHeap . elements , 1 , data . length ) ; newHeap . size = data . length ; for ( int i = newHeap . size / 2 ; i > 0 ; i -- ) { newHeap . percolateDown ( i ) ; } return newHeap ; }
Given an array of Comparables, return a binary heap of those elements.
Given an array of Comparables return a binary heap of those elements .