Class ActiveWaits
java.lang.Object
it.univr.di.cstnu.util.ActiveWaits
Active wait for a timepoint.
The scope of this class is to maintain the list of active waits for a node, allowing a fast determination of the greatest wait and fast removal of useless waits.
For these reasons, a max priority queue with the key the wait value and value of the associated contingent node is used.
Since the library has a minimum priority queue implementation, I reuse it, making it private and providing all the proper methods for manipulating it as a maximum priority queue.
Assumption The wait values are positive integers because it is supposed to manage waits at runtime.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal voidaddWait(LabeledNode contingent, int value) Add an active wait represented as (Contingent, positive value) to the queue.final intfinal booleanremove(LabeledNode contingent) Remove the wait associated with the contingent from the queue.final intsize()final StringtoString()
-
Constructor Details
-
ActiveWaits
public ActiveWaits()
-
-
Method Details
-
addWait
Add an active wait represented as (Contingent, positive value) to the queue.- Parameters:
contingent- the contingent node.value- the positive value representing the wait.
-
getMaximum
public final int getMaximum()- Returns:
- the maximum wait value presented in the queue if the queue is not empty,
Constants.INT_NULLotherwise.
-
remove
Remove the wait associated with the contingent from the queue.- Parameters:
contingent- node to remove- Returns:
- true if the wait associated with the contingent node was removed.
-
size
public final int size()- Returns:
- the number of active waits
-
toString
-