Package repast.simphony.engine.schedule
Class ActionQueue
java.lang.Object
repast.simphony.engine.schedule.ActionQueue
A priority queue containing ISchedulableAction-s. The actions are ordered
according to the return value of their
getNextTime()
method
call.
This priority queue uses a binary heap algorithm as described in Mark Allen Weis, _Algorithms, Data Structures, and Problem Solving with C++_, chapter 20.
- Author:
- Nick Collier
- See Also:
-
Constructor Summary
ConstructorDescriptionCreates an ActionQueue with a default initial size of 13.ActionQueue
(int size) Creates an ActionQueue with the specified initial size. -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Removes all elements from the queue.void
fixHeap()
Reinstate the heap order.int
Retrieves the number of actions whoseISchedulableAction.isNonModelAction()
method returns false.void
insert
(ISchedulableAction action) Insert the specified action into the queue.boolean
isEmpty()
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.int
size()
Gets the number of elements in the queue.void
toss
(ISchedulableAction action) Insert the specified action into the queue without maintain heap order.boolean
voidAction
(ISchedulableAction action) Find the specified Action in the queue and void it.
-
Constructor Details
-
ActionQueue
public ActionQueue()Creates an ActionQueue with a default initial size of 13. -
ActionQueue
public ActionQueue(int size) Creates an ActionQueue with the specified initial size.- Parameters:
size
- the intial size of the queue
-
-
Method Details
-
voidAction
Find the specified Action in the queue and void it. Voiding means replace that action with an empty action that does nothing.- Returns:
- returns true if the action is found and voided, false if this ActionQueue does not contain the specified AbstractAction.
-
insert
Insert the specified action into the queue. -
peekMin
Get 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
-
popMin
Remove 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
-
toss
Insert the specified action into the queue without maintain heap order.- Parameters:
action
- the action to insert into the queue
-
clear
public void clear()Removes all elements from the queue. -
fixHeap
public void fixHeap()Reinstate the heap order. This will fix the tree ordering it correctly. -
isEmpty
public boolean isEmpty()Returns true if the queue is empty, otherwise false.- Returns:
- true if the queue is empty, otherwise false.
-
size
public int size()Gets the number of elements in the queue.- Returns:
- the number of elements in the queue.
-
getModelActionCount
public int getModelActionCount()Retrieves the number of actions whoseISchedulableAction.isNonModelAction()
method returns false.- Returns:
- the number of model actions
-