java.lang.Object
org.maxicp.state.datastructures.StateInterval
Implementation of an interval that can saved and restored through
the
StateManager.saveState() / StateManager.restoreState()
methods.-
Constructor Summary
ConstructorsConstructorDescriptionStateInterval(StateManager sm, int min, int max) Creates an interval that can be saved and restored with theStateManager.saveState()/StateManager.restoreState()methods. -
Method Summary
Modifier and TypeMethodDescriptionbooleancontains(int val) Checks if the a given value in the intervalintfillArray(int[] dest) Sets the first values ofdestto the ones present in the interval.booleanisEmpty()Checks if the interval is empty.intmax()Returns the maximum value in the interval.intmin()Returns the minimum value in the interval.voidremoveAbove(int value) Updates the maximum value of the interval to the given one if it is less than the currentmax().voidEmpties the interval.voidremoveAllBut(int v) Reduces the interval to a single value.voidremoveBelow(int value) Updates the minimum value of the interval to the given one if it is larger than the currentmin().intsize()Returns the number of integer values in the interval.toString()
-
Constructor Details
-
StateInterval
Creates an interval that can be saved and restored with theStateManager.saveState()/StateManager.restoreState()methods.- Parameters:
sm- the state-manager that save and restore the state of this intervalmin- the minimum value of the intervalmax- the maximum value of the intervalmax >= 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 ofdestto the ones present in the interval.- Parameters:
dest- , an array large enoughdest.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 currentmin().- 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 currentmax().- Parameters:
value- the maximum to set
-
toString
-