Class FloatSemiIndirectHeaps
A semiindirect heap is based on a reference array. Elements of a semiindirect heap are integers that index the reference array (note that in an indirect heap you can also map elements of the reference array to heap positions).

Method Summary
Modifier and TypeMethodDescriptionstatic int
downHeap
(float[] refArray, int[] heap, int size, int i, FloatComparator c) Moves the given element down into the semiindirect heap until it reaches the lowest possible position.static int
front
(float[] refArray, int[] heap, int size, int[] a) Retrieves the front of a heap in a given array.static int
front
(float[] refArray, int[] heap, int size, int[] a, FloatComparator c) Retrieves the front of a heap in a given array using a given comparator.static void
makeHeap
(float[] refArray, int[] heap, int size, FloatComparator c) Creates a semiindirect heap from a given index array.static void
makeHeap
(float[] refArray, int offset, int length, int[] heap, FloatComparator c) Creates a semiindirect heap in the given array.static int[]
makeHeap
(float[] refArray, int offset, int length, FloatComparator c) Creates a semiindirect heap, allocating its heap array.static int
upHeap
(float[] refArray, int[] heap, int size, int i, FloatComparator c) Moves the given element up in the semiindirect heap until it reaches the highest possible position.

Method Details

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

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

makeHeap
public static void makeHeap(float[] refArray, int offset, int length, int[] heap, FloatComparator c) Creates a semiindirect heap in the given array. Parameters:
refArray
 the reference array.offset
 the first element of the reference array to be put in the heap.length
 the number of elements to be put in the heap.heap
 the array where the heap is to be created.c
 a typespecific comparator, ornull
for the natural order.

makeHeap
Creates a semiindirect heap, allocating its heap array. Parameters:
refArray
 the reference array.offset
 the first element of the reference array to be put in the heap.length
 the number of elements to be put in the heap.c
 a typespecific comparator, ornull
for the natural order. Returns:
 the heap array.

makeHeap
Creates a semiindirect heap from a given index array. Parameters:
refArray
 the reference array.heap
 an array containing indices intorefArray
.size
 the number of elements in the heap.c
 a typespecific comparator, ornull
for the natural order.

front
public static int front(float[] refArray, int[] heap, int size, int[] a) Retrieves the front of a heap in a given array.The front of a semiindirect heap is the set of indices whose associated elements in the reference array are equal to the element associated to the first index.
In several circumstances you need to know the front, and scanning linearly the entire heap is not the best strategy. This method simulates (using a partial linear scan) a breadthfirst visit that terminates when all visited nodes are larger than the element associated to the top index, which implies that no elements of the front can be found later. In most cases this trick yields a significant improvement.
 Parameters:
refArray
 the reference array.heap
 an array containing indices intorefArray
.size
 the number of elements in the heap.a
 an array large enough to hold the front (e.g., at least long asrefArray
). Returns:
 the number of elements actually written (starting from the first position of
a
).

front
Retrieves the front of a heap in a given array using a given comparator.The front of a semiindirect heap is the set of indices whose associated elements in the reference array are equal to the element associated to the first index.
In several circumstances you need to know the front, and scanning linearly the entire heap is not the best strategy. This method simulates (using a partial linear scan) a breadthfirst visit that terminates when all visited nodes are larger than the element associated to the top index, which implies that no elements of the front can be found later. In most cases this trick yields a significant improvement.
 Parameters:
refArray
 the reference array.heap
 an array containing indices intorefArray
.size
 the number of elements in the heap.a
 an array large enough to hold the front (e.g., at least long asrefArray
).c
 a typespecific comparator. Returns:
 the number of elements actually written (starting from the first position of
a
).
