public class StateLazySparseSet extends Object
Constructor and Description |
---|
StateLazySparseSet(StateManager sm,
int n,
int ofs)
Creates a set containing the elements {@code {ofs,ofs+1,...
|
Modifier and Type | Method and Description |
---|---|
boolean |
contains(int val)
Checks if a value is in the set.
|
int |
fillArray(int[] dest)
Sets the first values of
dest to the ones
present in the set. |
boolean |
isEmpty() |
int |
max()
Returns the maximum value in the set.
|
int |
min()
Returns the minimum value in the set.
|
boolean |
remove(int val)
Removes the given value from the set.
|
void |
removeAbove(int value)
Remove all the values larger than the given value from the set
|
void |
removeAll()
Removes all the values in the set.
|
void |
removeAllBut(int v)
Removes all the element from the set except the given value.
|
void |
removeBelow(int value)
Remove all the values less than the given value from the set
|
int |
size() |
String |
toString() |
public StateLazySparseSet(StateManager sm, int n, int ofs)
{ofs,ofs+1,...,ofs+n-1}
.sm
- the state manager that will save and restore the set when
StateManager.saveState()
/ StateManager.restoreState()
mehtods are calledn
- the number of elements in the setofs
- the minimum value in the set containing {ofs,ofs+1,...,ofs+n-1}
public boolean isEmpty()
public int size()
public int min()
public int max()
public boolean contains(int val)
val
- the value to checkpublic int fillArray(int[] dest)
dest
to the ones
present in the set.dest,
- an array large enough dest.length >= size()
public boolean remove(int val)
val
- the value to remove.public void removeAllBut(int v)
v
- is an element in the setpublic void removeAll()
public void removeBelow(int value)
value
- a value such that all the ones smaller are removedpublic void removeAbove(int value)
value
- a value such that all the ones greater are removedCopyright © 2018 Laurent Michel, Pierre Schaus, Pascal Van Hentenryck. All rights reserved.