|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--JavaTron.PriorityQueue
This class implements a 'PriorityQueue'. This is not a priority queue in the classic sense as usually implemented by a heap. It is rather a simple structure that allows an external user to add an item to a one queue in a list of prioritized queues.
There are n prioritized queue's, initialized at creation. The PriorityQueue will remove all items from its internal prioritized queue number 0 before removing items from number 1, and then from number 2 and so on.
There are no means for changing the priority of items in the queue, so items placed in queues higher than 0 could be starved.
Constructor Summary | |
PriorityQueue(int number)
Construct a PriorityQueue with number internal prioritized queues. |
Method Summary | |
void |
add(java.lang.Object item,
int priority)
Add an item to the queue using the specified priority. |
boolean |
isEmpty()
Returns true if all prioritized queues are empty. |
java.lang.Object |
remove()
Removes the next item from the prioritized queues in order of the queues. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public PriorityQueue(int number)
number
- the number of internal queues to holdMethod Detail |
public void add(java.lang.Object item, int priority)
item
- the item to addpriority
- the prioritized queue to add the item to where
0 <= priority < number where number is the initial
number of prioritized queues that were created in
the constructor.
ArrayOutOfBoundsException
- if !(0 <= priority < number)public boolean isEmpty()
public java.lang.Object remove()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |