Package com.ibm.wala.util.intset
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
public class MutableSparseIntSet extends SparseIntSet implements MutableIntSet, Serializable
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:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class com.ibm.wala.util.intset.SparseIntSet
elements, size
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
MutableSparseIntSet()
protected
MutableSparseIntSet(int[] backingStore)
protected
MutableSparseIntSet(IntSet set)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
add(int value)
Add an integer value to this set.boolean
addAll(IntSet set)
Add all elements from another int set.boolean
addAll(SparseIntSet that)
Add all elements from another int set.boolean
addAllInIntersection(IntSet other, IntSet filter)
void
clear()
remove all elements from this setvoid
copySet(IntSet that)
Set the value of this to be the same as the value of setstatic MutableSparseIntSet
createMutableSparseIntSet(int initialCapacity)
static MutableSparseIntSet
diff(MutableSparseIntSet A, MutableSparseIntSet B)
float
getExpansionFactor()
int
getInitialNonEmptySize()
void
intersectWith(IntSet set)
Intersect this with another set.void
intersectWith(SparseIntSet set)
static MutableSparseIntSet
make(IntSet set)
static MutableSparseIntSet
makeEmpty()
boolean
remove(int value)
Remove an integer from this set.void
removeAll(BitVectorIntSet v)
void
removeAll(MutableSparseIntSet set)
TODO optimize<T extends BitVectorBase<T>>
voidremoveAll(T v)
-
Methods inherited from class com.ibm.wala.util.intset.SparseIntSet
add, contains, containsAny, containsAny, diff, diffInternal, elementAt, foreach, foreachExcluding, getIndex, intersection, intIterator, isEmpty, isSubset, max, pair, parseIntArray, sameValue, singleton, size, toIntArray, toString, union
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.ibm.wala.util.intset.IntSet
contains, containsAny, foreach, foreachExcluding, intersection, intIterator, isEmpty, isSubset, max, sameValue, size, union
-
-
-
-
Constructor Detail
-
MutableSparseIntSet
protected MutableSparseIntSet(IntSet set)
-
MutableSparseIntSet
protected MutableSparseIntSet(int[] backingStore)
-
MutableSparseIntSet
protected MutableSparseIntSet()
-
-
Method Detail
-
clear
public void clear()
Description copied from interface:MutableIntSet
remove all elements from this set- Specified by:
clear
in interfaceMutableIntSet
-
remove
public boolean remove(int value)
Description copied from interface:MutableIntSet
Remove an integer from this set.- Specified by:
remove
in 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:MutableIntSet
Add an integer value to this set.- Specified by:
add
in interfaceMutableIntSet
- Parameters:
value
-- Returns:
- true iff this value changes
-
copySet
public void copySet(IntSet that) throws IllegalArgumentException
Description copied from interface:MutableIntSet
Set the value of this to be the same as the value of set- Specified by:
copySet
in interfaceMutableIntSet
- Throws:
IllegalArgumentException
- if that == null
-
intersectWith
public void intersectWith(IntSet set)
Description copied from interface:MutableIntSet
Intersect this with another set.- Specified by:
intersectWith
in interfaceMutableIntSet
-
intersectWith
public void intersectWith(SparseIntSet set)
-
addAll
public boolean addAll(IntSet set) throws IllegalArgumentException
Add all elements from another int set.- Specified by:
addAll
in interfaceMutableIntSet
- Returns:
- true iff this set changes
- Throws:
IllegalArgumentException
- if set == null
-
addAll
public boolean addAll(SparseIntSet that)
Add all elements from another int set.- Parameters:
that
-- Returns:
- true iff this set changes
-
removeAll
public void removeAll(BitVectorIntSet v)
-
removeAll
public <T extends BitVectorBase<T>> void removeAll(T v)
-
removeAll
public void removeAll(MutableSparseIntSet set)
TODO optimize- Parameters:
set
-- Throws:
IllegalArgumentException
- if set is null
-
addAllInIntersection
public boolean addAllInIntersection(IntSet other, IntSet filter)
- Specified by:
addAllInIntersection
in interfaceMutableIntSet
-
diff
public static MutableSparseIntSet diff(MutableSparseIntSet A, MutableSparseIntSet B)
-
make
public static MutableSparseIntSet make(IntSet set)
-
makeEmpty
public static MutableSparseIntSet makeEmpty()
-
createMutableSparseIntSet
public static MutableSparseIntSet createMutableSparseIntSet(int initialCapacity) throws IllegalArgumentException
- Throws:
IllegalArgumentException
-
-