public class IntegerSet
extends java.lang.Object
This class is intentionally missing a size method.
Constructor and Description |
---|
IntegerSet(int maximumCount)
Initialize a lookup table with the given maximum number of elements.
|
IntegerSet(int maximumCount,
java.util.Collection<java.lang.Integer> values)
Initialize a lookup table with a given maximum and value list.
|
Modifier and Type | Method and Description |
---|---|
void |
add(int element)
Add the given element to the set, or do nothing if it already exists.
|
void |
addAll(java.util.Collection<java.lang.Integer> packets)
Add the given collection of elements to the set.
|
void |
clear()
Remove every element from the set.
|
boolean |
contains(int element)
Determine whether or not the given element exists in the set.
|
void |
remove(int element)
Remove the given element from the set, or do nothing if it's already removed.
|
java.util.Set<java.lang.Integer> |
toSet()
Convert the current IntegerSet to an equivalent HashSet.
|
public IntegerSet(int maximumCount)
This creates a set for elements in the range [0, count).
Formally, the current set must be a subset of [0, 1, 2, ..., count - 1].
maximumCount
- - maximum element value and count.public IntegerSet(int maximumCount, java.util.Collection<java.lang.Integer> values)
The provided elements must be in the range [0, count).
maximumCount
- - the maximum element value and count.values
- - the elements to add to the set.public boolean contains(int element)
element
- - the element to check. Must be in the range [0, count).public void add(int element)
element
- - element to add.OutOfBoundsException
- If the given element is not in the range [0, count).public void addAll(java.util.Collection<java.lang.Integer> packets)
packets
- - elements to add.public void remove(int element)
element
- - element to remove.public void clear()
public java.util.Set<java.lang.Integer> toSet()