public class SparseIntSet extends Object implements IntSet, Serializable
Modifier and Type | Field and Description |
---|---|
protected int[] |
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 |
---|---|
|
SparseIntSet()
Subclasses should use this with extreme care.
|
protected |
SparseIntSet(int size) |
protected |
SparseIntSet(int[] backingArray)
Subclasses should use this with extreme care.
|
|
SparseIntSet(IntSet S) |
protected |
SparseIntSet(SparseIntSet S) |
Modifier and Type | Method and Description |
---|---|
static SparseIntSet |
add(SparseIntSet s,
int j) |
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[] |
diffInternal(SparseIntSet A,
SparseIntSet B) |
int |
elementAt(int idx) |
void |
foreach(IntSetAction action)
Invoke an action on each element of the Set
|
void |
foreachExcluding(IntSet X,
IntSetAction action)
Invoke an action on each element of the Set, excluding elements of Set X
|
int |
getIndex(int x) |
IntSet |
intersection(IntSet that)
This implementation must not despoil the original value of "this"
|
IntIterator |
intIterator() |
boolean |
isEmpty() |
boolean |
isSubset(IntSet that) |
int |
max() |
static SparseIntSet |
pair(int i,
int j) |
static int[] |
parseIntArray(String str)
Reverse of toString(): "{2,3}" -> [2,3]
|
boolean |
sameValue(IntSet that) |
static SparseIntSet |
singleton(int i) |
int |
size() |
int[] |
toIntArray() |
String |
toString() |
IntSet |
union(IntSet that)
This implementation must not despoil the original value of "this"
|
protected int[] elements
protected int size
protected SparseIntSet(int size)
protected SparseIntSet(int[] backingArray)
public SparseIntSet()
protected SparseIntSet(SparseIntSet S)
public SparseIntSet(IntSet S) throws IllegalArgumentException
IllegalArgumentException
public final boolean contains(int x)
contains
in interface IntSet
IntSet.contains(int)
public final int getIndex(int x)
public final int size()
public final boolean isEmpty()
public final int elementAt(int idx) throws NoSuchElementException
NoSuchElementException
public boolean sameValue(IntSet that) throws IllegalArgumentException, UnimplementedError
sameValue
in interface IntSet
this
has the same value as that
.IllegalArgumentException
UnimplementedError
public static SparseIntSet diff(SparseIntSet A, SparseIntSet B)
public static int[] diffInternal(SparseIntSet A, SparseIntSet B)
public static int[] parseIntArray(String str)
IllegalArgumentException
- if str is nullpublic static SparseIntSet singleton(int i)
public static SparseIntSet pair(int i, int j)
public IntSet intersection(IntSet that)
IntSet
intersection
in interface IntSet
public IntSet union(IntSet that)
IntSet
public IntIterator intIterator()
intIterator
in interface IntSet
public final int max() throws IllegalStateException
max
in interface IntSet
IllegalStateException
public void foreach(IntSetAction action)
IntSet
public void foreachExcluding(IntSet X, IntSetAction action)
IntSet
foreachExcluding
in interface IntSet
public static SparseIntSet add(SparseIntSet s, int j)
IllegalArgumentException
- if s is nullpublic boolean isSubset(IntSet that)
public boolean containsAny(IntSet set)
containsAny
in interface IntSet
public boolean containsAny(SparseIntSet set) throws IllegalArgumentException
IllegalArgumentException
public int[] toIntArray()