|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--lu.cs.co.util.PriorityQueue
A priority queue. The elements of the queue must implement the Comparable interface of java.lang. The priority is given by the ordering induced by the compareTo method. It is required that all elements in the queue can be compared by this method. Note that the smaller objects (with respect to the ordering induced by the compareTo method) have lower priority, and that the findMin() and deleteMin() methods return the lowest priority element. To insert objects that do not implement the Comparable interface (or to insert such elements with a different ordering), use the class ObjectWithPriority.
Comparable| Constructor Summary | |
PriorityQueue()
Constructs an empty queue. |
|
PriorityQueue(int n)
Constructs an empty queue. |
|
| Method Summary | |
Object |
deleteMin()
Removes the lowest priority element of the queue. |
Object |
findMin()
Return the lowest priority element in the queue. |
void |
insert(Comparable x)
Insert an element into the queue. |
boolean |
isEmpty()
Return true iff this queue is empty |
int |
size()
Returns queue's size (number of elements). |
void |
toss(Comparable x)
Insert an element into the queue. |
| Methods inherited from class java.lang.Object |
equals,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
| Constructor Detail |
public PriorityQueue(int n)
n - a reasonable upper bound on the queue's size (the queue
will increase its capacity automatically if this bound is
violated, but starting with a good bound improves performance)public PriorityQueue()
| Method Detail |
public int size()
public boolean isEmpty()
public Object findMin()
public void toss(Comparable x)
public void insert(Comparable x)
public Object deleteMin()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||