|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.arsdigita.util.PriorityQueue
A simple priority queue that is implemented by a backing tree set. Ordering of the dequeues (ascending or descending) is specified at creation time. Note that this class defers synchronization to the user.
Constructor Summary | |
PriorityQueue()
Creates a new PriorityQueue that orders dequeues in ascending order (lowest priority first) |
|
PriorityQueue(boolean ascending)
Creates a new PriorityQueue that orders dequeues in either ascending or descending order. |
Method Summary | |
Object |
dequeue()
Return the next object in the queue, removing it from the queue. |
void |
enqueue(Object object,
int priority)
Adds a new object to the queue with a given priority. |
boolean |
isEmpty()
Returns true if the queue is empty, false otherwise |
Object |
peek()
Return the next object in the queue. |
void |
setAscending(boolean ascending)
Changes the dequeue ordering. |
int |
size()
Returns the number of objects in the queue |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public PriorityQueue()
public PriorityQueue(boolean ascending)
ascending
- true for ascending order, false otherwiseMethod Detail |
public Object dequeue()
NoSuchElementException
- if the queue is emptypublic Object peek()
NoSuchElementException
- if the queue is emptypublic void enqueue(Object object, int priority)
object
- the Object to addpriority
- the Object's priority in the queuepublic boolean isEmpty()
public void setAscending(boolean ascending)
ascending
- true for ascending order, false for descendingpublic int size()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |