Class ActiveWaits

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

public class ActiveWaits extends Object
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.
  • 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 not empty, Constants.INT_NULL otherwise.
    • remove

      public boolean remove(@Nonnull LabeledNode contingent)
      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

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