Module org.maxicp

Class StateInterval

java.lang.Object
org.maxicp.state.datastructures.StateInterval

public class StateInterval extends Object
Implementation of an interval that can saved and restored through the StateManager.saveState() / StateManager.restoreState() methods.
  • Constructor Summary

    Constructors
    Constructor
    Description
    StateInterval(StateManager sm, int min, int max)
    Creates an interval that can be saved and restored with the StateManager.saveState() / StateManager.restoreState() methods.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    contains(int val)
    Checks if the a given value in the interval
    int
    fillArray(int[] dest)
    Sets the first values of dest to the ones present in the interval.
    boolean
    Checks if the interval is empty.
    int
    max()
    Returns the maximum value in the interval.
    int
    min()
    Returns the minimum value in the interval.
    void
    removeAbove(int value)
    Updates the maximum value of the interval to the given one if it is less than the current max().
    void
    Empties the interval.
    void
    removeAllBut(int v)
    Reduces the interval to a single value.
    void
    removeBelow(int value)
    Updates the minimum value of the interval to the given one if it is larger than the current min().
    int
    Returns the number of integer values in the interval.
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • StateInterval

      public StateInterval(StateManager sm, int min, int max)
      Creates an interval that can be saved and restored with the StateManager.saveState() / StateManager.restoreState() methods.
      Parameters:
      sm - the state-manager that save and restore the state of this interval
      min - the minimum value of the interval
      max - the maximum value of the interval max >= min
  • Method Details

    • isEmpty

      public boolean isEmpty()
      Checks if the interval is empty.
      Returns:
      true if the set is empty
    • size

      public int size()
      Returns the number of integer values in the interval.
      Returns:
      the size of the set
    • min

      public int min()
      Returns the minimum value in the interval.
      Returns:
      the minimum value in the set
    • max

      public int max()
      Returns the maximum value in the interval.
      Returns:
      the maximum value in the set
    • contains

      public boolean contains(int val)
      Checks if the a given value in the interval
      Parameters:
      val - the value to check check.
      Returns:
      true if the value is in the interval
    • fillArray

      public int fillArray(int[] dest)
      Sets the first values of dest to the ones present in the interval.
      Parameters:
      dest - , an array large enough dest.length >= size()
      Returns:
      the size of the set
    • removeAllBut

      public void removeAllBut(int v)
      Reduces the interval to a single value.
      Parameters:
      v - is an element in the set
    • removeAll

      public void removeAll()
      Empties the interval.
    • removeBelow

      public void removeBelow(int value)
      Updates the minimum value of the interval to the given one if it is larger than the current min().
      Parameters:
      value - the minimum to set
    • removeAbove

      public void removeAbove(int value)
      Updates the maximum value of the interval to the given one if it is less than the current max().
      Parameters:
      value - the maximum to set
    • toString

      public String toString()
      Overrides:
      toString in class Object