com.apamax.containers
Event Heap


A Max/Min-value Heap object with configurable type comparators.

Create with a comparator object determining the Heap order and comparison function.

Several built-in comparators are available.
See Also:
com.apamax.containers.HeapIntegerFieldComparator - 
com.apamax.containers.HeapIntegerComparator - 
com.apamax.containers.HeapStringComparator - 

Action summary
 integerstatic create(any comparator)

Create an empty heap with the given comparator. The comparator determines if this is a min-heap or a max-heap and how to compare the values.
 booleanempty()

Returns true if the heap is empty.
 integerstatic heapify(sequence<any> data, any comparator)

Create an in-place heap on the given sequence, with the given comparator. The comparator determines if this is a min-heap or a max-heap and how to compare the values.
 anypeekTop()

Return the top value from the heap, according to its comparator.
 anypop()

Remove and return the top value from the heap, according to its comparator, maintaining the heap.
 voidpush(any val)

Push a new value into the heap, maintaining the heap.
 integersize()

Returns the number of values in the heap.
 
Action detail

create

integer static create(any comparator)
Create an empty heap with the given comparator. The comparator determines if this is a min-heap or a max-heap and how to compare the values.
Parameters:
comparator - A Comparator object with a compare action with the signature action<any, any> returns integer.

empty

boolean empty()
Returns true if the heap is empty.

heapify

integer static heapify(sequence<any> data, any comparator)
Create an in-place heap on the given sequence, with the given comparator. The comparator determines if this is a min-heap or a max-heap and how to compare the values.
Parameters:
data - A sequence which will be heapified in-place and further heap operations will be made on the array.
comparator - A Comparator object with a compare action with the signature action<any, any> returns integer.

peekTop

any peekTop()
Return the top value from the heap, according to its comparator.

pop

any pop()
Remove and return the top value from the heap, according to its comparator, maintaining the heap.

push

void push(any val)
Push a new value into the heap, maintaining the heap.
Parameters:
val - The value to add to the heap.

size

integer size()
Returns the number of values in the heap.