edu.wpi.prc.task.queue
Class MultiPriorityQueue.MultiPriorityQueueIterator<P extends T>
java.lang.Object
edu.wpi.prc.task.queue.MultiPriorityQueue.MultiPriorityQueueIterator<P>
- Type Parameters:
P
-
- All Implemented Interfaces:
- java.util.Iterator<P>
- Enclosing class:
- MultiPriorityQueue<T extends Prioritizable>
private class MultiPriorityQueue.MultiPriorityQueueIterator<P extends T>
- extends java.lang.Object
- implements java.util.Iterator<P>
This is the iterator for the MultiPriorityQueue. It returns all objects
in FIFO order from the highest-priority queue, then moves to the next-
highest-priority queue, returns the objects in that queue in FIFO order,
and so on.
- Author:
- James Baldassari
Field Summary |
private java.util.ArrayList<P> |
elements
|
private int |
index
|
private java.util.SortedSet<java.lang.Integer> |
priorities
|
private java.util.Map<java.lang.Integer,java.util.LinkedList<P>> |
queues
|
Constructor Summary |
MultiPriorityQueue.MultiPriorityQueueIterator(java.util.SortedSet<java.lang.Integer> priorities,
java.util.Map<java.lang.Integer,java.util.LinkedList<P>> queues,
int size)
The constructor stores a copy of the MultiPriorityQueue. |
Method Summary |
boolean |
hasNext()
|
P |
next()
|
private void |
populateElements()
Creates a simple array of the elements from the MultiPriorityQueue
in the correct order (by priority, then FIFO). |
void |
remove()
Removes the current element. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
priorities
private java.util.SortedSet<java.lang.Integer> priorities
queues
private java.util.Map<java.lang.Integer,java.util.LinkedList<P extends T>> queues
elements
private java.util.ArrayList<P extends T> elements
index
private int index
MultiPriorityQueue.MultiPriorityQueueIterator
public MultiPriorityQueue.MultiPriorityQueueIterator(java.util.SortedSet<java.lang.Integer> priorities,
java.util.Map<java.lang.Integer,java.util.LinkedList<P>> queues,
int size)
- The constructor stores a copy of the MultiPriorityQueue.
- Parameters:
priorities
- The priorities of the queues.queues
- The queues of objects.size
- The number of objects in the MultiPriorityQueue.
populateElements
private void populateElements()
- Creates a simple array of the elements from the MultiPriorityQueue
in the correct order (by priority, then FIFO).
hasNext
public boolean hasNext()
- Specified by:
hasNext
in interface java.util.Iterator<P extends T>
- Returns:
- Returns true if the iterator has another element to return,
false otherwise.
next
public P next()
- Specified by:
next
in interface java.util.Iterator<P extends T>
- Returns:
- Returns the next element.
remove
public void remove()
- Removes the current element.
- Specified by:
remove
in interface java.util.Iterator<P extends T>