public class LimitedSizeIntSet
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable
The advantage of this class over LimitedSizeSet<Integer>
is that it does not autobox
the int values, so it takes less memory.
LimitedSizeSet
,
Serialized FormModifier and Type | Field and Description |
---|---|
protected int[] |
values
If null, then at least numValues distinct values have been seen.
|
Constructor and Description |
---|
LimitedSizeIntSet(@Positive int maxValues)
Create a new LimitedSizeIntSet that can hold maxValues values.
|
Modifier and Type | Method and Description |
---|---|
void |
add(int elt)
Add an element to this set.
|
void |
addAll(LimitedSizeIntSet s)
Add all elements of
s to this set. |
LimitedSizeIntSet |
clone() |
boolean |
contains(int elt)
Return true if this set contains the given element.
|
@Positive int |
maxSize()
An upper bound on how many distinct elements can be individually represented in the set.
|
static LimitedSizeIntSet |
merge(@Positive int maxValues,
java.util.List<LimitedSizeIntSet> slist)
Merges a list of
LimitedSizeIntSet objects into a single object that represents the
values seen by the entire list. |
boolean |
repNulled()
Returns true if more elements have been added than this set can contain (which is the integer
that was passed to the constructor when creating this set).
|
int |
size()
A lower bound on the number of elements in the set.
|
java.lang.String |
toString() |
protected int[] values
public LimitedSizeIntSet(@Positive int maxValues)
maxValues
- the maximum number of values this set will be able to hold; must be positivepublic void add(int elt)
elt
- the element to add to this setpublic void addAll(LimitedSizeIntSet s)
s
to this set.s
- the elements to add to this set@Pure public boolean contains(int elt)
elt
- the element whose membership to testelt
@Pure public int size(@GuardSatisfied LimitedSizeIntSet this)
public @Positive int maxSize()
@EnsuresNonNullIf(result=false, expression="values") @Pure public boolean repNulled(@GuardSatisfied LimitedSizeIntSet this)
@SideEffectFree public LimitedSizeIntSet clone(@GuardSatisfied LimitedSizeIntSet this)
clone
in class java.lang.Object
public static LimitedSizeIntSet merge(@Positive int maxValues, java.util.List<LimitedSizeIntSet> slist)
LimitedSizeIntSet
objects into a single object that represents the
values seen by the entire list. Returns the new object, whose maxValues is the given integer.maxValues
- the maximum size for the returned LimitedSizeIntSetslist
- a list of LimitedSizeIntSet, whose elements will be merged@SideEffectFree public java.lang.String toString(@GuardSatisfied LimitedSizeIntSet this)
toString
in class java.lang.Object