|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.wpi.prc.task.queue.MultiPriorityQueue<T>
T
- The type of Prioritizable to store in this MultiPriorityQueue.public class MultiPriorityQueue<T extends Prioritizable>
Stores queues of Prioritizable objects. Although it appears as a single queue when iterating over it, the MultiPriorityQueue actually stores many different queues internally. Each internal queue is associated with a different priority. When iterating over the queue it is guaranteed that higher-priority objects will be returned before lower-priority ones. If two objects in the queue have the same priority, normal FIFO queue semantics are obeyed. When an iterator is requested, a copy of the MultiPriorityQueue is made, and the iterator uses the copy. Therefore, if the MultiPriorityQueue is modified after an iterator is returned, a new iterator will need to be requested for those changes to be returned by the iterator.
Nested Class Summary | |
---|---|
private class |
MultiPriorityQueue.MultiPriorityQueueIterator<P extends T>
This is the iterator for the MultiPriorityQueue. |
Field Summary | |
---|---|
private java.util.SortedSet<java.lang.Integer> |
priorities
|
private java.util.Map<java.lang.Integer,java.util.LinkedList<T>> |
queues
|
private static long |
serialVersionUID
|
(package private) int |
size
|
Constructor Summary | |
---|---|
MultiPriorityQueue()
|
Method Summary | ||
---|---|---|
boolean |
add(T t)
Adds the given object to the MultiPriorityQueue. |
|
boolean |
addAll(java.util.Collection<? extends T> t)
Adds all objects in the given collection to the MultiPriorityQueue. |
|
boolean |
addAll(T[] tArray)
Adds all objects in the given array to the MultiPriorityQueue. |
|
void |
clear()
Removes all objects from the MultiPriorityQueue. |
|
boolean |
contains(java.lang.Object obj)
Searches through the MultiPriorityQueue for the given object. |
|
boolean |
containsAll(java.util.Collection<?> c)
Checks whether all of the objects in the given collection appear in the MultiPriorityQueue. |
|
T |
first()
|
|
boolean |
isEmpty()
|
|
java.util.Iterator<T> |
iterator()
Returns an iterator for this MultiPriorityQueue. |
|
T |
peek()
|
|
boolean |
remove(java.lang.Object obj)
Removes the given object from the MultiPriorityQueue. |
|
boolean |
removeAll(java.util.Collection<?> c)
Removes all objects contained in the given collection from the MultiPriorityQueue. |
|
T |
removeFirst()
Removes the first (highest-priority) object in the MultiPriorityQueue and returns it. |
|
boolean |
retainAll(java.util.Collection<?> c)
Removes all objects from the MultiPriorityQueue except the objects contained in the given collection. |
|
int |
size()
|
|
java.lang.Object[] |
toArray()
|
|
|
toArray(P[] arg0)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface java.util.Set |
---|
equals, hashCode |
Field Detail |
---|
private static final long serialVersionUID
private java.util.SortedSet<java.lang.Integer> priorities
private java.util.Map<java.lang.Integer,java.util.LinkedList<T extends Prioritizable>> queues
int size
Constructor Detail |
---|
public MultiPriorityQueue()
Method Detail |
---|
public java.util.Iterator<T> iterator()
iterator
in interface java.lang.Iterable<T extends Prioritizable>
iterator
in interface java.util.Collection<T extends Prioritizable>
iterator
in interface java.util.Set<T extends Prioritizable>
public int size()
size
in interface java.util.Collection<T extends Prioritizable>
size
in interface java.util.Set<T extends Prioritizable>
public boolean isEmpty()
isEmpty
in interface java.util.Collection<T extends Prioritizable>
isEmpty
in interface java.util.Set<T extends Prioritizable>
public boolean contains(java.lang.Object obj)
contains
in interface java.util.Collection<T extends Prioritizable>
contains
in interface java.util.Set<T extends Prioritizable>
obj
- The object to search for.
public boolean containsAll(java.util.Collection<?> c)
containsAll
in interface java.util.Collection<T extends Prioritizable>
containsAll
in interface java.util.Set<T extends Prioritizable>
c
- The collection of objects to check for.
public boolean add(T t)
add
in interface java.util.Collection<T extends Prioritizable>
add
in interface java.util.Set<T extends Prioritizable>
t
- The object to add.
public boolean addAll(java.util.Collection<? extends T> t)
addAll
in interface java.util.Collection<T extends Prioritizable>
addAll
in interface java.util.Set<T extends Prioritizable>
t
- The collection containing objects to add.
public boolean addAll(T[] tArray)
addAll
in interface TransitionerQueue<T extends Prioritizable>
tArray
- The array containing objects to add.
public boolean remove(java.lang.Object obj)
remove
in interface java.util.Collection<T extends Prioritizable>
remove
in interface java.util.Set<T extends Prioritizable>
obj
- The object to remove.
public T removeFirst()
removeFirst
in interface TransitionerQueue<T extends Prioritizable>
public boolean removeAll(java.util.Collection<?> c)
removeAll
in interface java.util.Collection<T extends Prioritizable>
removeAll
in interface java.util.Set<T extends Prioritizable>
c
- The collection of objects to remove.
public boolean retainAll(java.util.Collection<?> c)
retainAll
in interface java.util.Collection<T extends Prioritizable>
retainAll
in interface java.util.Set<T extends Prioritizable>
c
- The collection of objects to retain.
public T peek()
public T first()
first
in interface TransitionerQueue<T extends Prioritizable>
public void clear()
clear
in interface java.util.Collection<T extends Prioritizable>
clear
in interface java.util.Set<T extends Prioritizable>
public java.lang.Object[] toArray()
toArray
in interface java.util.Collection<T extends Prioritizable>
toArray
in interface java.util.Set<T extends Prioritizable>
public <P> P[] toArray(P[] arg0)
toArray
in interface java.util.Collection<T extends Prioritizable>
toArray
in interface java.util.Set<T extends Prioritizable>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |