|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--javaslam.util.PriorityQueue
A priority queue.
Nested Class Summary | |
protected class |
PriorityQueue.QueueElement
An item in a priority queue. |
protected class |
PriorityQueue.QueueItemIterator
An iterator over queue items. |
Field Summary | |
protected ArrayList |
elements
A list of QueueElement objects ordered by
their priorities. |
protected Map |
itemsToElements
Maps items to their elements. |
Constructor Summary | |
PriorityQueue()
Constructor. |
Method Summary | |
void |
clear()
Removes all items from this queue. |
Object |
dequeue()
Dequeues the item with the highest priority. |
void |
enqueue(Object item,
Comparable priority)
Enqueues a new item with the supplied priority. |
Comparable |
highest()
Returns the priority of the highest priority item in the queue. |
boolean |
isEmpty()
Returns true iff this queue is empty. |
Iterator |
iterator()
Returns an iterator over the items in this priority queue in order of decreasing priority. |
Object |
peek()
Returns the item with the highest priority without removing it from the queue. |
void |
remove(Object item)
Removes a particular item from the queue, if it exists. |
void |
reprioritize(Object item,
Comparable priority)
Updates the priority of an item already in the queue. |
int |
size()
Returns the number of items in this queue. |
String |
toString()
Returns a string representation of this priority queue. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected ArrayList elements
QueueElement
objects ordered by
their priorities.
protected Map itemsToElements
Constructor Detail |
public PriorityQueue()
Method Detail |
public boolean isEmpty()
true
iff this queue is empty.
public Iterator iterator()
public int size()
public void clear()
public void enqueue(Object item, Comparable priority)
item
to priority
.
item
- the new item to enqueuepriority
- the priority of the new item
ClassCastException
- if the supplied priority is not
comparable to the priorities of the
previously enqueued itemspublic Object dequeue()
null
is returned.
null
if this queue is emptypublic void remove(Object item)
item
- the item to be removedpublic Object peek()
null
is returned.
null
if this queue is emptypublic Comparable highest()
null
if this queue is emptypublic void reprioritize(Object item, Comparable priority)
item
- the item whose priority is to be changedpriority
- the new priority of the item
ClassCastException
- if the supplied priority is not
comparable to the priorities of the
previously enqueued itemspublic String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |