Class Heap |
A Heap is a dense binary tree ordered as a priority queue. The priority order is from lowest to highest priority where the priority of two elements can be compared through the results of invoking the operation f on each. The priority operation p defaults to "<" but can be any binary comparison operation.
Both f and p may be any of lang::Closure, procedure, function, integer, or string-invocation symbol. f is invoked with a single argument (a heap element) and p is invoked to compare the results of two calls to f.
Details |
Constructor |
S | optional list of initial values to insert into heap |
fVal | a lang::Closure, procedure, integer, or
string-invocation to use in comparisons. When needed,
the operation is invoked with a single argument that is
a heap element. Defaults to 1 [i.e. the identity operation] |
pVal | a lang::Closure, procedure, integer, or
string-invocation implementing a comparison operation
on the results of invoking fVal on two Heap elements.
Defaults to "<" |
Construct a Heap.
Methods: |
a | element to add
|
a |
Add a new element to the heap.
the heap elements(non-destructively) in order |
the next heap element (destructively, in order) |
the number of heap elements |
the top of the heap (non-destructively) |
Fields: |