public class SparseLongSet extends Object implements LongSet
Modifier and Type | Field and Description |
---|---|
protected long[] |
elements
The backing store of int arrays
|
protected int |
size
The number of entries in the backing store that are valid.
|
Modifier | Constructor and Description |
---|---|
|
SparseLongSet()
Subclasses should use this with extreme care.
|
protected |
SparseLongSet(int size) |
|
SparseLongSet(IntSet S) |
protected |
SparseLongSet(long[] backingArray)
Subclasses should use this with extreme care.
|
protected |
SparseLongSet(SparseLongSet S) |
Modifier and Type | Method and Description |
---|---|
static SparseLongSet |
add(SparseLongSet s,
int j) |
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.
|
long |
elementAt(int idx) |
void |
foreach(LongSetAction action)
Invoke an action on each element of the Set
|
void |
foreachExcluding(LongSet X,
LongSetAction action)
Invoke an action on each element of the Set, excluding elements of Set X
|
int |
getIndex(long x) |
LongSet |
intersection(LongSet that)
This implementation must not despoil the original value of "this"
|
boolean |
isEmpty() |
boolean |
isSubset(LongSet that) |
LongIterator |
longIterator() |
long |
max() |
static SparseLongSet |
pair(long i,
long j) |
static long[] |
parseLongArray(String str)
Reverse of toString(): "{2,3}" -> [2,3]
|
boolean |
sameValue(LongSet that) |
static SparseLongSet |
singleton(int i) |
int |
size() |
String |
toString() |
protected long[] elements
protected int size
protected SparseLongSet(int size)
size
- protected SparseLongSet(long[] backingArray)
backingArray
- public SparseLongSet()
protected SparseLongSet(SparseLongSet S)
public SparseLongSet(IntSet S) throws IllegalArgumentException
IllegalArgumentException
public final boolean contains(long x)
contains
in interface LongSet
IntSet.contains(int)
public final int getIndex(long x)
x
- public final int size()
public final boolean isEmpty()
public final long elementAt(int idx) throws NoSuchElementException
NoSuchElementException
public boolean sameValue(LongSet that) throws IllegalArgumentException, UnimplementedError
sameValue
in interface LongSet
this
has the same value as
that
.IllegalArgumentException
UnimplementedError
public static SparseLongSet diff(SparseLongSet A, SparseLongSet B)
IllegalArgumentException
- if A is nullpublic static long[] parseLongArray(String str) throws NumberFormatException, IllegalArgumentException
IllegalArgumentException
- if str is nullNumberFormatException
public static SparseLongSet singleton(int i)
public static SparseLongSet pair(long i, long j)
public LongSet intersection(LongSet that) throws IllegalArgumentException, UnimplementedError
LongSet
intersection
in interface LongSet
IllegalArgumentException
UnimplementedError
public LongIterator longIterator()
longIterator
in interface LongSet
public void foreach(LongSetAction action)
LongSet
public void foreachExcluding(LongSet X, LongSetAction action)
LongSet
foreachExcluding
in interface LongSet
public final long max() throws IllegalStateException
max
in interface LongSet
IllegalStateException
public static SparseLongSet add(SparseLongSet s, int j)
public boolean isSubset(LongSet that) throws IllegalArgumentException, UnimplementedError
isSubset
in interface LongSet
this
is a subset of that
.IllegalArgumentException
UnimplementedError
public boolean containsAny(LongSet set)
containsAny
in interface LongSet
public boolean containsAny(SparseLongSet set) throws IllegalArgumentException
IllegalArgumentException