@Override public void changed() { ObjectHeaps.downHeap(heap, size, 0, c); } @Override
/** * Makes an array into a heap. * * @param heap * the heap (starting at 0). * @param size * the number of elements in the heap. * @param c * a type-specific comparator, or {@code null} for the natural order. */ public static <K> void makeHeap(final K[] heap, final int size, final Comparator<K> c) { int i = size >>> 1; while (i-- != 0) downHeap(heap, size, i, c); } }
@Override public K dequeue() { if (size == 0) throw new NoSuchElementException(); final K result = heap[0]; heap[0] = heap[--size]; heap[size] = null; if (size != 0) ObjectHeaps.downHeap(heap, size, 0, c); return result; } @Override