Class MutableSparseIntSet
java.lang.Object
com.ibm.wala.util.intset.SparseIntSet
com.ibm.wala.util.intset.MutableSparseIntSet
- All Implemented Interfaces:
IntSet, MutableIntSet, Serializable
- Direct Known Subclasses:
TunedMutableSparseIntSet
A sparse ordered, mutable duplicate-free, fully-encapsulated set of integers. Instances are not
canonical, except for EMPTY.
This implementation will be inefficient if these sets get large.
TODO: even for small sets, we probably want to work on this to reduce the allocation activity.
- See Also:
-
Field Summary
Fields inherited from class SparseIntSet
elements, size -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedprotectedMutableSparseIntSet(int[] backingStore) protectedMutableSparseIntSet(@Nullable IntSet set) -
Method Summary
Modifier and TypeMethodDescriptionbooleanadd(int value) Add an integer value to this set.booleanaddAll(@Nullable SparseIntSet that) Add all elements from another int set.booleanAdd all elements from another int set.booleanaddAllInIntersection(IntSet other, IntSet filter) voidclear()remove all elements from this setvoidSet the value of this to be the same as the value of setstatic MutableSparseIntSetcreateMutableSparseIntSet(int initialCapacity) static MutableSparseIntSetfloatintvoidintersectWith(IntSet set) Intersect this with another set.voidintersectWith(SparseIntSet that) static MutableSparseIntSetstatic MutableSparseIntSetbooleanremove(int value) Remove an integer from this set.voidvoidTODO optimize<T extends BitVectorBase<T>>
voidremoveAll(T v) Methods inherited from class SparseIntSet
add, contains, containsAny, containsAny, diff, diffInternal, elementAt, foreach, foreachExcluding, getIndex, intersection, intIterator, isEmpty, isSubset, max, pair, parseIntArray, sameValue, singleton, size, toIntArray, toString, unionModifier and TypeMethodDescriptionstatic SparseIntSetadd(SparseIntSet s, int j) final booleancontains(int x) Does this set contain value x?booleancontainsAny(IntSet set) booleancontainsAny(SparseIntSet set) static SparseIntSetdiff(SparseIntSet A, SparseIntSet B) Compute the asymmetric difference of two sets, a \ b.static int[]final intelementAt(int idx) voidforeach(IntSetAction action) Invoke an action on each element of the SetvoidforeachExcluding(IntSet X, IntSetAction action) Invoke an action on each element of the Set, excluding elements of Set Xfinal intgetIndex(int x) intersection(IntSet that) This implementation must not despoil the original value of "this"final booleanisEmpty()booleanfinal intmax()static SparseIntSetpair(int i, int j) static int[]parseIntArray(String str) Reverse of toString(): "{2,3}" -> [2,3]booleanstatic SparseIntSetsingleton(int i) final intsize()int[]toString()This implementation must not despoil the original value of "this"
-
Constructor Details
-
MutableSparseIntSet
-
MutableSparseIntSet
protected MutableSparseIntSet(int[] backingStore) -
MutableSparseIntSet
protected MutableSparseIntSet()
-
-
Method Details
-
clear
public void clear()Description copied from interface:MutableIntSetremove all elements from this set- Specified by:
clearin interfaceMutableIntSet
-
remove
@NullUnmarked public boolean remove(int value) Description copied from interface:MutableIntSetRemove an integer from this set.- Specified by:
removein interfaceMutableIntSet- Parameters:
value- integer to remove- Returns:
- true iff the value of this changes.
-
getInitialNonEmptySize
public int getInitialNonEmptySize() -
getExpansionFactor
public float getExpansionFactor() -
add
public boolean add(int value) Description copied from interface:MutableIntSetAdd an integer value to this set.- Specified by:
addin interfaceMutableIntSet- Parameters:
value- integer to add- Returns:
- true iff this value changes
-
copySet
Description copied from interface:MutableIntSetSet the value of this to be the same as the value of set- Specified by:
copySetin interfaceMutableIntSet- Throws:
IllegalArgumentException- if that == null
-
intersectWith
Description copied from interface:MutableIntSetIntersect this with another set.- Specified by:
intersectWithin interfaceMutableIntSet
-
intersectWith
-
addAll
Add all elements from another int set.- Specified by:
addAllin interfaceMutableIntSet- Returns:
- true iff this set changes
- Throws:
IllegalArgumentException- if set == null
-
addAll
Add all elements from another int set.- Returns:
- true iff this set changes
-
removeAll
-
removeAll
-
removeAll
TODO optimize- Throws:
IllegalArgumentException- if set is null
-
addAllInIntersection
- Specified by:
addAllInIntersectionin interfaceMutableIntSet
-
diff
-
make
-
makeEmpty
-
createMutableSparseIntSet
public static MutableSparseIntSet createMutableSparseIntSet(int initialCapacity) throws IllegalArgumentException - Throws:
IllegalArgumentException
-