
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_ |
A heap-based priority queue. The class currently uses a standard array-based heap, as described in, for example, Sedgewick's Algorithms text. All methods are fully synchronized.
| alma::ACS::jbaci::Heap::Heap | ( | int | capacity, | |
| Comparator | cmp | |||
| ) | throws IllegalArgumentException [inline] |
| alma::ACS::jbaci::Heap::Heap | ( | int | capacity | ) | [inline] |
Create a Heap with the given capacity, and relying on natural ordering.
| capacity | initial capacity. |
| synchronized void alma::ACS::jbaci::Heap::clear | ( | ) | [inline] |
Remove all elements.
References count_, and nodes_.
Referenced by alma::ACS::jbaci::BACITimer::shutDown().
| int alma::ACS::jbaci::Heap::compare | ( | Object | a, | |
| Object | b | |||
| ) | [inline, protected] |
| synchronized Object alma::ACS::jbaci::Heap::extract | ( | ) | [inline] |
| synchronized void alma::ACS::jbaci::Heap::insert | ( | Object | x | ) | [inline] |
Insert an element, resize if necessary.
| x | object to insert. |
References compare(), count_, nodes_, and parent().
Referenced by alma::ACS::jbaci::BACITimer::executeAfterDelay(), alma::ACS::jbaci::BACITimer::executeAt(), alma::ACS::jbaci::BACITimer::executePeriodically(), and alma::ACS::jbaci::BACITimer::nextTask().
| final int alma::ACS::jbaci::Heap::left | ( | int | k | ) | [inline, protected] |
Get left child.
Referenced by extract().
| final int alma::ACS::jbaci::Heap::parent | ( | int | k | ) | [inline, protected] |
Get parent index.
Referenced by insert().
| synchronized Object alma::ACS::jbaci::Heap::peek | ( | ) | [inline] |
Return least element without removing it, or null if empty.
References count_, and nodes_.
Referenced by alma::ACS::jbaci::BACITimer::nextTask().
| final int alma::ACS::jbaci::Heap::right | ( | int | k | ) | [inline, protected] |
Get right child.
Referenced by extract().
| synchronized int alma::ACS::jbaci::Heap::size | ( | ) | [inline] |
final Comparator alma::ACS::jbaci::Heap::cmp_ [protected] |
int alma::ACS::jbaci::Heap::count_ = 0 [protected] |
Object [] alma::ACS::jbaci::Heap::nodes_ [protected] |
1.6.2