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 java.lang.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)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(java.lang.String str)Reverse of toString(): "{2,3}" -> [2,3]booleansameValue(LongSet that)static SparseLongSetsingleton(int i)intsize()java.lang.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
public SparseLongSet()
Subclasses should use this with extreme care.
-
SparseLongSet
protected SparseLongSet(SparseLongSet S)
-
SparseLongSet
public SparseLongSet(IntSet S) throws java.lang.IllegalArgumentException
- Throws:
java.lang.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 java.util.NoSuchElementException- Throws:
java.util.NoSuchElementException
-
sameValue
public boolean sameValue(LongSet that) throws java.lang.IllegalArgumentException, UnimplementedError
- Specified by:
sameValuein interfaceLongSet- Returns:
- true iff
thishas the same value asthat. - Throws:
java.lang.IllegalArgumentExceptionUnimplementedError
-
diff
public static SparseLongSet diff(SparseLongSet A, SparseLongSet B)
Compute the asymmetric difference of two sets, a \ b.- Throws:
java.lang.IllegalArgumentException- if A is null
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
parseLongArray
public static long[] parseLongArray(java.lang.String str) throws java.lang.NumberFormatException, java.lang.IllegalArgumentExceptionReverse of toString(): "{2,3}" -> [2,3]- Throws:
java.lang.IllegalArgumentException- if str is nulljava.lang.NumberFormatException
-
singleton
public static SparseLongSet singleton(int i)
-
pair
public static SparseLongSet pair(long i, long j)
-
intersection
public LongSet intersection(LongSet that) throws java.lang.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:
java.lang.IllegalArgumentExceptionUnimplementedError
-
longIterator
public LongIterator longIterator()
- Specified by:
longIteratorin interfaceLongSet- Returns:
- a perhaps more efficient iterator
-
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 java.lang.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 java.lang.IllegalArgumentException, UnimplementedError
- Specified by:
isSubsetin interfaceLongSet- Returns:
- true iff
thisis a subset ofthat. - Throws:
java.lang.IllegalArgumentExceptionUnimplementedError
-
containsAny
public boolean containsAny(LongSet set)
- Specified by:
containsAnyin interfaceLongSet- Returns:
- true iff this set contains integer i
-
containsAny
public boolean containsAny(SparseLongSet set) throws java.lang.IllegalArgumentException
- Throws:
java.lang.IllegalArgumentException
-
-