public class StateInterval extends Object
StateManager.saveState()
/ StateManager.restoreState()
methods.Constructor and Description |
---|
StateInterval(StateManager sm,
int min,
int max)
Creates an interval that can be saved and restored
with the
StateManager.saveState() / StateManager.restoreState()
methods. |
Modifier and Type | Method and 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 |
isEmpty()
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 |
removeAll()
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 |
size()
Returns the number of integer values in the interval.
|
String |
toString() |
public StateInterval(StateManager sm, int min, int max)
StateManager.saveState()
/ StateManager.restoreState()
methods.sm
- the state-manager that save and restore the state of this intervalmin
- the minimum value of the intervalmax
- the maximum value of the interval max >= min
public boolean isEmpty()
public int size()
public int min()
public int max()
public boolean contains(int val)
val
- the value to check check.public int fillArray(int[] dest)
dest
to the ones
present in the interval.dest,
- an array large enough dest.length >= size()
public void removeAllBut(int v)
v
- is an element in the setpublic void removeAll()
public void removeBelow(int value)
min()
.value
- the minimum to setpublic void removeAbove(int value)
max()
.value
- the maximum to setCopyright © 2018 Laurent Michel, Pierre Schaus, Pascal Van Hentenryck. All rights reserved.