java.lang.Object
org.maxicp.state.datastructures.StateLazySparseSet
A sparse-set that lazily switch
from a dense interval representation
to a sparse-set representation
when a hole is created in the interval.
-
Constructor Summary
ConstructorsConstructorDescriptionStateLazySparseSet(StateManager sm, int n, int ofs) Creates a set containing the elements{ofs,ofs+1,...,ofs+n-1}. -
Method Summary
Modifier and TypeMethodDescriptionbooleancontains(int val) Checks if a value is in the set.intfillArray(int[] dest) Sets the first values ofdestto the ones present in the set.intfillDeltaArray(int oldMin, int oldMax, int oldSize, int[] arr) booleanisEmpty()intmax()Returns the maximum value in the set.intmin()Returns the minimum value in the set.booleanremove(int val) Removes the given value from the set.voidremoveAbove(int value) Remove all the values larger than the given value from the setvoidRemoves all the values in the set.voidremoveAllBut(int v) Removes all the element from the set except the given value.voidremoveBelow(int value) Remove all the values less than the given value from the setintsize()toString()
-
Constructor Details
-
StateLazySparseSet
Creates a set containing the elements{ofs,ofs+1,...,ofs+n-1}.- Parameters:
sm- the state manager that will save and restore the set whenStateManager.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}
-
-
Method Details
-
isEmpty
public boolean isEmpty()- Returns:
- true if the set is empty
-
size
public int size()- Returns:
- the size of the set
-
min
public int min()Returns the minimum value in the set.- Returns:
- the minimum value in the set
-
max
public int max()Returns the maximum value in the set.- Returns:
- the maximum value in the set
-
contains
public boolean contains(int val) Checks if a value is in the set.- Parameters:
val- the value to check- Returns:
- true if val is in the set
-
fillArray
public int fillArray(int[] dest) Sets the first values ofdestto the ones present in the set.- Parameters:
dest- , an array large enoughdest.length >= size()- Returns:
- the size of the set
-
remove
public boolean remove(int val) Removes the given value from the set.- Parameters:
val- the value to remove.- Returns:
- true if val was in the set, false otherwise
-
removeAllBut
public void removeAllBut(int v) Removes all the element from the set except the given value.- Parameters:
v- is an element in the set
-
removeAll
public void removeAll()Removes all the values in the set. -
removeBelow
public void removeBelow(int value) Remove all the values less than the given value from the set- Parameters:
value- a value such that all the ones smaller are removed
-
removeAbove
public void removeAbove(int value) Remove all the values larger than the given value from the set- Parameters:
value- a value such that all the ones greater are removed
-
toString
-
fillDeltaArray
public int fillDeltaArray(int oldMin, int oldMax, int oldSize, int[] arr)
-