Class ActiveWaits

java.lang.Object
it.univr.di.cstnu.util.ActiveWaits

public class ActiveWaits extends Object
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 Details

    • ActiveWaits

      public ActiveWaits()
  • Method Details

    • addWait

      public void addWait(LabeledNode contingent, int value)
      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 is not empty, Constants.INT_NULL otherwise.
    • remove

      public boolean remove(@Nonnull LabeledNode contingent)
      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 int size()
      Returns:
      the number of active waits
    • toString

      public String toString()
      Overrides:
      toString in class Object
      Returns:
      the string representation. Beware that values are negated in this representation.