Package com.ibm.wala.util.intset
Class SparseLongSet
- java.lang.Object
-
- com.ibm.wala.util.intset.SparseLongSet
-
- All Implemented Interfaces:
LongSet
- Direct Known Subclasses:
MutableSparseLongSet
public class SparseLongSet extends Object implements LongSet
A sparse ordered, duplicate-free, fully-encapsulated set of longs; not necessary mutable
-
-
Constructor Summary
Constructors Modifier Constructor Description SparseLongSet()Subclasses should use this with extreme care.protectedSparseLongSet(int size)protectedSparseLongSet(long[] backingArray)Subclasses should use this with extreme care.SparseLongSet(IntSet S)protectedSparseLongSet(SparseLongSet S)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static SparseLongSetadd(SparseLongSet s, int j)booleancontains(long x)Does this set contain value x?booleancontainsAny(LongSet set)booleancontainsAny(SparseLongSet set)static SparseLongSetdiff(SparseLongSet A, SparseLongSet B)Compute the asymmetric difference of two sets, a \ b.longelementAt(int idx)voidforeach(LongSetAction action)Invoke an action on each element of the SetvoidforeachExcluding(LongSet X, LongSetAction action)Invoke an action on each element of the Set, excluding elements of Set XintgetIndex(long x)@Nullable LongSetintersection(LongSet that)This implementation must not despoil the original value of "this"booleanisEmpty()booleanisSubset(LongSet that)LongIteratorlongIterator()longmax()static SparseLongSetpair(long i, long j)static long[]parseLongArray(String str)Reverse of toString(): "{2,3}" -> [2,3]booleansameValue(LongSet that)static SparseLongSetsingleton(int i)intsize()StringtoString()
-
-
-
Constructor Detail
-
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
protected SparseLongSet(SparseLongSet S)
-
SparseLongSet
public SparseLongSet(IntSet S) throws IllegalArgumentException
- Throws:
IllegalArgumentException
-
-
Method Detail
-
contains
public final boolean contains(long x)
Does this set contain value x?- Specified by:
containsin interfaceLongSet- Returns:
- true iff this set contains long i
- See Also:
IntSet.contains(int)
-
getIndex
public final int getIndex(long x)
- Returns:
- index i s.t. elements[i] == x, or -1 if not found.
-
size
public final int size()
-
isEmpty
public final boolean isEmpty()
-
elementAt
public final long elementAt(int idx) throws NoSuchElementException- Throws:
NoSuchElementException
-
sameValue
public boolean sameValue(LongSet that) throws IllegalArgumentException, UnimplementedError
- Specified by:
sameValuein interfaceLongSet- Returns:
- true iff
thishas the same value asthat. - Throws:
IllegalArgumentExceptionUnimplementedError
-
diff
public static SparseLongSet diff(SparseLongSet A, SparseLongSet B)
Compute the asymmetric difference of two sets, a \ b.- Throws:
IllegalArgumentException- if A is null
-
parseLongArray
public static long[] parseLongArray(String str) throws NumberFormatException, IllegalArgumentException
Reverse of toString(): "{2,3}" -> [2,3]- Throws:
IllegalArgumentException- if str is nullNumberFormatException
-
singleton
public static SparseLongSet singleton(int i)
-
pair
public static SparseLongSet pair(long i, long j)
-
intersection
public @Nullable LongSet intersection(LongSet that) throws IllegalArgumentException, UnimplementedError
Description copied from interface:LongSetThis implementation must not despoil the original value of "this"- Specified by:
intersectionin interfaceLongSet- Returns:
- a new IntSet which is the intersection of this and that
- Throws:
IllegalArgumentExceptionUnimplementedError- See Also:
IntSet.intersection(com.ibm.wala.util.intset.IntSet)
-
longIterator
public LongIterator longIterator()
- Specified by:
longIteratorin interfaceLongSet- Returns:
- a perhaps more efficient iterator
- See Also:
IntSet.intIterator()
-
foreach
public void foreach(LongSetAction action)
Description copied from interface:LongSetInvoke an action on each element of the Set
-
foreachExcluding
public void foreachExcluding(LongSet X, LongSetAction action)
Description copied from interface:LongSetInvoke an action on each element of the Set, excluding elements of Set X- Specified by:
foreachExcludingin interfaceLongSet
-
max
public final long max() throws IllegalStateException- Specified by:
maxin interfaceLongSet- Returns:
- the largest element in the set
- Throws:
IllegalStateException
-
add
public static SparseLongSet add(SparseLongSet s, int j)
- Returns:
- a new sparse int set which adds j to s
-
isSubset
public boolean isSubset(LongSet that) throws IllegalArgumentException, UnimplementedError
- Specified by:
isSubsetin interfaceLongSet- Returns:
- true iff
thisis a subset ofthat. - Throws:
IllegalArgumentExceptionUnimplementedError- See Also:
IntSet.isSubset(com.ibm.wala.util.intset.IntSet)
-
containsAny
public boolean containsAny(LongSet set)
- Specified by:
containsAnyin interfaceLongSet- Returns:
- true iff this set contains integer i
- See Also:
IntSet.containsAny(com.ibm.wala.util.intset.IntSet)
-
containsAny
public boolean containsAny(SparseLongSet set) throws IllegalArgumentException
- Throws:
IllegalArgumentException
-
-