MutableArray elements;
public int length;
[elements length].
public mutable selector compare_selector;
i_compare_r will be used.
boolean max_heap;
TRUE, this is a heap of which the root node is the
largest. Otherwise, the root is the smallest node.
id init;
[self init TRUE].
id (self) init boolean root_is_max;
boolean dump_simple_p;
NO.
_builtin_.Any extract_min pre !max_heap;
_builtin_.Any (object) min pre !max_heap;
nil if the heap is empty.
_builtin_.Any extract_max pre max_heap;
_builtin_.Any (object) max pre max_heap;
nil if the heap is empty.
_builtin_.Any (object) extract_root pre length > 0 post length >= 0 && [object heap_index] == 0;
object of the heap.
_builtin_.Any (object) root pre length > 0;
object of the heap, without extracting it.
void remove HeapElement elt pre [elt heap_index] > 0 && elements[([elt heap_index] - 1)] == elt post [elt heap_index] == 0;
elt from the receiving heap. The elt must be an
element of the heap.
void add HeapElement object pre [object heap_index] == 0 post length == 1 + old length;
object to this Heap. It may not yet be part of any
(other) heap, as stated by the precondition.
void addElementsFromEnumerator Enumerator e;
void empty;
Enumerator enumerator;
protected void build_heap;
elements.
int compare (Comparable, Comparable) (one, other);
one compare itself with the other, either using the
compare_selector, or, if not set, the int compare id method.
protected void heapify int index;
i (which is off by 1 compared to
the index of the element in the elements array).