Class SparseIntSet
java.lang.Object
com.ibm.wala.util.intset.SparseIntSet
- All Implemented Interfaces:
IntSet, Serializable
- Direct Known Subclasses:
MutableSparseIntSet
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionSubclasses should use this with extreme care.protectedSparseIntSet(int size) protectedSparseIntSet(int[] backingArray) Subclasses should use this with extreme care.protected -
Method Summary
Modifier 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"
-
Field Details
-
elements
protected int[] elementsThe backing store of int arrays -
size
protected int sizeThe number of entries in the backing store that are valid.
-
-
Constructor Details
-
SparseIntSet
protected SparseIntSet(int size) -
SparseIntSet
protected SparseIntSet(int[] backingArray) Subclasses should use this with extreme care. Do not allow the backing array to escape elsewhere. -
SparseIntSet
@NullUnmarked public SparseIntSet()Subclasses should use this with extreme care. -
SparseIntSet
-
SparseIntSet
- Throws:
IllegalArgumentException
-
-
Method Details
-
contains
-
getIndex
public final int getIndex(int x) - Returns:
- index i s.t. elements[i] == x, or -1 if not found.
-
size
-
isEmpty
-
elementAt
- Throws:
NoSuchElementException
-
sameValue
- Specified by:
sameValuein interfaceIntSet- Returns:
- true iff
thishas the same value asthat. - Throws:
IllegalArgumentExceptionUnimplementedError
-
diff
Compute the asymmetric difference of two sets, a \ b. -
diffInternal
-
toString
-
parseIntArray
Reverse of toString(): "{2,3}" -> [2,3]- Throws:
IllegalArgumentException- if str is null
-
singleton
-
pair
-
intersection
Description copied from interface:IntSetThis implementation must not despoil the original value of "this"- Specified by:
intersectionin interfaceIntSet- Returns:
- a new IntSet which is the intersection of this and that
-
union
-
intIterator
- Specified by:
intIteratorin interfaceIntSet- Returns:
- a perhaps more efficient iterator
-
max
- Specified by:
maxin interfaceIntSet- Returns:
- the largest element in the set
- Throws:
IllegalStateException
-
foreach
Description copied from interface:IntSetInvoke an action on each element of the Set -
foreachExcluding
Description copied from interface:IntSetInvoke an action on each element of the Set, excluding elements of Set X- Specified by:
foreachExcludingin interfaceIntSet- See Also:
-
add
- Returns:
- a new sparse int set which adds j to s
- Throws:
IllegalArgumentException- if s is null
-
isSubset
-
containsAny
- Specified by:
containsAnyin interfaceIntSet- Returns:
- true iff this set contains integer i
-
containsAny
- Throws:
IllegalArgumentException
-
toIntArray
public int[] toIntArray()- Returns:
- contents as an int[]
-