Class SparseLongSet
java.lang.Object
com.ibm.wala.util.intset.SparseLongSet
- All Implemented Interfaces:
LongSet
- Direct Known Subclasses:
MutableSparseLongSet
A sparse ordered, duplicate-free, fully-encapsulated set of longs; not necessary mutable
-
Field Summary
-
Constructor Summary
ModifierConstructorDescriptionSubclasses should use this with extreme care.protected
SparseLongSet
(int size) //////////////////////////////////////////////////////////////////////////protected
SparseLongSet
(long[] backingArray) Subclasses should use this with extreme care.protected
-
Method Summary
Modifier and TypeMethodDescriptionstatic SparseLongSet
add
(SparseLongSet s, int j) final boolean
contains
(long x) Does this set contain value x?boolean
containsAny
(LongSet set) boolean
containsAny
(SparseLongSet set) static SparseLongSet
diff
(SparseLongSet A, SparseLongSet B) Compute the asymmetric difference of two sets, a \ b.final long
elementAt
(int idx) void
foreach
(LongSetAction action) Invoke an action on each element of the Setvoid
foreachExcluding
(LongSet X, LongSetAction action) Invoke an action on each element of the Set, excluding elements of Set Xfinal int
getIndex
(long x) @Nullable LongSet
intersection
(LongSet that) This implementation must not despoil the original value of "this"final boolean
isEmpty()
boolean
final long
max()
static SparseLongSet
pair
(long i, long j) static long[]
parseLongArray
(String str) Reverse of toString(): "{2,3}" -> [2,3]boolean
static SparseLongSet
singleton
(int i) final int
size()
toString()
-
Field Details
-
elements
protected long[] elementsThe backing store of int arrays -
size
protected int sizeThe number of entries in the backing store that are valid.
-
-
Constructor Details
-
SparseLongSet
protected SparseLongSet(int size) ////////////////////////////////////////////////////////////////////////// -
SparseLongSet
protected SparseLongSet(long[] backingArray) Subclasses should use this with extreme care. Do not allow the backing array to escape elsewhere. -
SparseLongSet
@NullUnmarked public SparseLongSet()Subclasses should use this with extreme care. -
SparseLongSet
-
SparseLongSet
- Throws:
IllegalArgumentException
-
-
Method Details
-
contains
-
getIndex
public final int getIndex(long x) - Returns:
- index i s.t. elements[i] == x, or -1 if not found.
-
size
-
isEmpty
-
elementAt
- Throws:
NoSuchElementException
-
sameValue
- Specified by:
sameValue
in interfaceLongSet
- Returns:
- true iff
this
has the same value asthat
. - Throws:
IllegalArgumentException
UnimplementedError
-
diff
Compute the asymmetric difference of two sets, a \ b.- Throws:
IllegalArgumentException
- if A is null
-
toString
-
parseLongArray
public static long[] parseLongArray(String str) throws NumberFormatException, IllegalArgumentException Reverse of toString(): "{2,3}" -> [2,3]- Throws:
IllegalArgumentException
- if str is nullNumberFormatException
-
singleton
-
pair
-
intersection
public @Nullable LongSet intersection(LongSet that) throws IllegalArgumentException, UnimplementedError Description copied from interface:LongSet
This implementation must not despoil the original value of "this"- Specified by:
intersection
in interfaceLongSet
- Returns:
- a new IntSet which is the intersection of this and that
- Throws:
IllegalArgumentException
UnimplementedError
- See Also:
-
longIterator
- Specified by:
longIterator
in interfaceLongSet
- Returns:
- a perhaps more efficient iterator
- See Also:
-
foreach
Description copied from interface:LongSet
Invoke an action on each element of the Set -
foreachExcluding
Description copied from interface:LongSet
Invoke an action on each element of the Set, excluding elements of Set X- Specified by:
foreachExcluding
in interfaceLongSet
-
max
- Specified by:
max
in interfaceLongSet
- Returns:
- the largest element in the set
- Throws:
IllegalStateException
-
add
- Returns:
- a new sparse int set which adds j to s
-
isSubset
- Specified by:
isSubset
in interfaceLongSet
- Returns:
- true iff
this
is a subset ofthat
. - Throws:
IllegalArgumentException
UnimplementedError
- See Also:
-
containsAny
- Specified by:
containsAny
in interfaceLongSet
- Returns:
- true iff this set contains integer i
- See Also:
-
containsAny
- Throws:
IllegalArgumentException
-