Package repast.simphony.util
Class PriorityQueue<T>
java.lang.Object
repast.simphony.util.PriorityQueue<T>
A priority queue where the items are ordered according to a
 specified comparator.
 This priority queue uses a binary heap algorithm as described in Mark Allen Weis,
 _Algorithms, Data Structures, and Problem Solving with C++_, chapter 20.
- Version:
- $Revision: 1.1 $ $Date: 2005/12/21 22:25:34 $
- Author:
- Nick Collier
- 
Constructor SummaryConstructorsConstructorDescriptionPriorityQueue(T minValue, Comparator<T> comp) Creates a PriorityQueue with a default initial size of 13.PriorityQueue(T minValue, Comparator<T> comp, int size) Creates a PriorityQueue with the specified initial size.
- 
Method SummaryModifier and TypeMethodDescriptionvoidclear()Removes all elements from the queue.voidfixHeap()Reinstate the heap order.voidInsert the specified item into the queue.booleanisEmpty()Returns true if the queue is empty, otherwise false.peekMin()Get the minimum element from the queque without removing it from the queue.popMin()Remove the minimum element from the queque and return it.intsize()Gets the number of elements in the queue.voidInsert the specified item into the queue without maintain heap order.
- 
Constructor Details- 
PriorityQueueCreates a PriorityQueue with a default initial size of 13. The minValue param is expected to less than any value put in the queue.- Parameters:
- minValue- the absolute minimum value put in the queue.
- comp- the comparator used to order the items in the queue.
 
- 
PriorityQueueCreates a PriorityQueue with the specified initial size. The minValue param is expected to less than any value put in the queue.- Parameters:
- minValue- the absolute minimum value put in the queue.
- comp- the comparator used to order the items in the queue.
- size- the intial size of the queue
 
 
- 
- 
Method Details- 
insertInsert the specified item into the queue.
- 
peekMinGet the minimum element from the queque without removing it from the queue. If heap order is not currently correct, the heap will be fixed before the minimum is returned.- Returns:
- the minimum element from the queque
 
- 
popMinRemove the minimum element from the queque and return it. If heap order is not currently correct, the heap will be fixed before the minimum is returned.- Returns:
- the minimum element from the queque
 
- 
tossInsert the specified item into the queue without maintain heap order.- Parameters:
- obj- the item to insert into the queue
 
- 
clearpublic void clear()Removes all elements from the queue.
- 
fixHeappublic void fixHeap()Reinstate the heap order. This will fix the tree, ordering it correctly.
- 
isEmptypublic boolean isEmpty()Returns true if the queue is empty, otherwise false.- Returns:
- true if the queue is empty, otherwise false.
 
- 
sizepublic int size()Gets the number of elements in the queue.- Returns:
- the number of elements in the queue.
 
 
-