Class SparseIntSet
java.lang.Object
com.ibm.wala.util.intset.SparseIntSet
- All Implemented Interfaces:
IntSet
,Serializable
- Direct Known Subclasses:
MutableSparseIntSet
A sparse ordered, duplicate-free, fully-encapsulated set of integers; not necessary mutable
- See Also:
-
Field Summary
-
Constructor Summary
ModifierConstructorDescriptionSubclasses should use this with extreme care.protected
SparseIntSet
(int size) protected
SparseIntSet
(int[] backingArray) Subclasses should use this with extreme care.protected
-
Method Summary
Modifier and TypeMethodDescriptionstatic SparseIntSet
add
(SparseIntSet s, int j) final boolean
contains
(int x) Does this set contain value x?boolean
containsAny
(IntSet set) boolean
containsAny
(SparseIntSet set) static SparseIntSet
diff
(SparseIntSet A, SparseIntSet B) Compute the asymmetric difference of two sets, a \ b.static int[]
final int
elementAt
(int idx) void
foreach
(IntSetAction action) Invoke an action on each element of the Setvoid
foreachExcluding
(IntSet X, IntSetAction action) Invoke an action on each element of the Set, excluding elements of Set Xfinal int
getIndex
(int x) intersection
(IntSet that) This implementation must not despoil the original value of "this"final boolean
isEmpty()
boolean
final int
max()
static SparseIntSet
pair
(int i, int j) static int[]
parseIntArray
(String str) Reverse of toString(): "{2,3}" -> [2,3]boolean
static SparseIntSet
singleton
(int i) final int
size()
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:
sameValue
in interfaceIntSet
- Returns:
- true iff
this
has the same value asthat
. - Throws:
IllegalArgumentException
UnimplementedError
-
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:IntSet
This implementation must not despoil the original value of "this"- Specified by:
intersection
in interfaceIntSet
- Returns:
- a new IntSet which is the intersection of this and that
-
union
-
intIterator
- Specified by:
intIterator
in interfaceIntSet
- Returns:
- a perhaps more efficient iterator
-
max
- Specified by:
max
in interfaceIntSet
- Returns:
- the largest element in the set
- Throws:
IllegalStateException
-
foreach
Description copied from interface:IntSet
Invoke an action on each element of the Set -
foreachExcluding
Description copied from interface:IntSet
Invoke an action on each element of the Set, excluding elements of Set X- Specified by:
foreachExcluding
in 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:
containsAny
in interfaceIntSet
- Returns:
- true iff this set contains integer i
-
containsAny
- Throws:
IllegalArgumentException
-
toIntArray
public int[] toIntArray()- Returns:
- contents as an int[]
-