Class ActiveWaits
java.lang.Object
it.univr.di.cstnu.util.ActiveWaits
Active wait of a timepoint.
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 removing of useless waits.
For these reasons, a max priority queue with key the wait value and value the associated contingent node is used.
Since the library has a min priority queue implementation, I reuse it making it private and giving all the proper methods for manipulating it as max priority queue. Assumption The wait values are positive integer because it is supposed to manage waits at runtime.
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 removing of useless waits.
For these reasons, a max priority queue with key the wait value and value the associated contingent node is used.
Since the library has a min priority queue implementation, I reuse it making it private and giving all the proper methods for manipulating it as max priority queue. Assumption The wait values are positive integer because it is supposed to manage waits at runtime.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addWait
(LabeledNode contingent, int value) Add an active wait represented as (Contingent, positive value) to the queue.int
boolean
remove
(LabeledNode contingent) Remove the wait associated to contingent from the queue.int
size()
toString()
-
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 int getMaximum()- Returns:
- the maximum wait value presented in the queue if the queue not empty,
Constants.INT_NULL
otherwise.
-
remove
Remove the wait associated to contingent from the queue.- Parameters:
contingent
- node to remove- Returns:
- true if the wait associated to the contingent node was removed.
-
size
public int size()- Returns:
- the number of active waits
-
toString
-