Public Member Functions | |
Heap (int capacity, Comparator cmp) throws IllegalArgumentException | |
Heap (int capacity) | |
synchronized void | insert (Object x) |
synchronized Object | extract () |
synchronized Object | peek () |
synchronized int | size () |
synchronized void | clear () |
Protected Member Functions | |
int | compare (Object a, Object b) |
final int | parent (int k) |
final int | left (int k) |
final int | right (int k) |
Protected Attributes | |
Object[] | nodes_ |
int | count_ = 0 |
final Comparator | cmp_ |
|
Create a Heap with the given initial capacity and comparator
|
|
Create a Heap with the given capacity, and relying on natural ordering.
|
|
Remove all elements. |
|
Perform element comparisons using comparator or natural ordering. |
|
Return and remove least element, or null if empty.
|
|
Insert an element, resize if necessary.
|
|
Get left child. |
|
Get parent index. |
|
Return least element without removing it, or null if empty.
|
|
Get right child. |
|
Return number of elements.
|
|
Ordering comparator. |
|
Number of used slots. |
|
The tree nodes, packed into an array. |