Package it.unimi.dsi.fastutil.shorts
Class ShortHeaps
java.lang.Object
it.unimi.dsi.fastutil.shorts.ShortHeaps
A class providing static methods and objects that do useful things with heaps.
The static methods of this class allow to treat arrays as 0based heaps. They are used in the implementation of heapbased queues, but they may be also used directly.

Method Summary
Modifier and TypeMethodDescriptionstatic int
downHeap
(short[] heap, int size, int i, ShortComparator c) Moves the given element down into the heap until it reaches the lowest possible position.static void
makeHeap
(short[] heap, int size, ShortComparator c) Makes an array into a heap.static int
upHeap
(short[] heap, int size, int i, ShortComparator c) Moves the given element up in the heap until it reaches the highest possible position.

Method Details

downHeap
Moves the given element down into the heap until it reaches the lowest possible position. Parameters:
heap
 the heap (starting at 0).size
 the number of elements in the heap.i
 the index of the element that must be moved down.c
 a typespecific comparator, ornull
for the natural order. Returns:
 the new position of the element of index
i
.

upHeap
Moves the given element up in the heap until it reaches the highest possible position. Parameters:
heap
 the heap (starting at 0).size
 the number of elements in the heap.i
 the index of the element that must be moved up.c
 a typespecific comparator, ornull
for the natural order. Returns:
 the new position of the element of index
i
.

makeHeap
Makes an array into a heap. Parameters:
heap
 the heap (starting at 0).size
 the number of elements in the heap.c
 a typespecific comparator, ornull
for the natural order.
