|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjjil.algorithm.BinaryHeap
public class BinaryHeap
Implements a binary heap. Note that all "matching" is based on the compareTo method.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface jjil.algorithm.PriorityQueue |
---|
PriorityQueue.Position |
Constructor Summary | |
---|---|
BinaryHeap()
Construct the binary heap. |
|
BinaryHeap(ComparableJ2me[] items)
Construct the binary heap from an array. |
Method Summary | |
---|---|
ComparableJ2me |
deleteMin()
Remove the smallest item from the priority queue. |
ComparableJ2me |
findMin()
Find the smallest item in the priority queue. |
PriorityQueue.Position |
insert(ComparableJ2me x)
Insert into the priority queue. |
boolean |
isEmpty()
Test if the priority queue is logically empty. |
void |
makeEmpty()
Make the priority queue logically empty. |
int |
size()
Returns size. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public BinaryHeap()
public BinaryHeap(ComparableJ2me[] items) throws Error
items
- the inital items in the binary heap.
Error
- if one of the objects compareTo method throws
jjil.core.Error.Method Detail |
---|
public PriorityQueue.Position insert(ComparableJ2me x) throws Error
insert
in interface PriorityQueue
x
- the item to insert.
Error
- if one of the objects in the priority queue throws jjil.core.Error when the
compareTo method is called.public ComparableJ2me findMin() throws Error
findMin
in interface PriorityQueue
Error
- if one of the objects in the priority queue throws jjil.core.Error when the
compareTo method is called.public ComparableJ2me deleteMin() throws Error
deleteMin
in interface PriorityQueue
Error
- if one of the objects in the priority queue throws jjil.core.Error when the
compareTo method is called.public boolean isEmpty()
isEmpty
in interface PriorityQueue
public int size()
size
in interface PriorityQueue
public void makeEmpty()
makeEmpty
in interface PriorityQueue
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |