T
- the type of the elementspublic class OpenIntToSet<T>
extends java.lang.Object
implements java.io.Serializable
This class provides a dedicated map from integers to Sets with a much smaller
memory overhead than standard java.util.Set
.
This class is not synchronized. The specialized iterators returned by
iterator()
are fail-fast: they throw a
ConcurrentModificationException
when they detect the map has
been modified during iteration.
Copied and modified from
org.apache.commons.math4.util-OpenIntToFieldHashMap
Modifier and Type | Class and Description |
---|---|
class |
OpenIntToSet.Iterator
Iterator class for the map.
|
Modifier and Type | Field and Description |
---|---|
protected static byte |
FREE
Status indicator for free table entries.
|
protected static byte |
FULL
Status indicator for full table entries.
|
protected static byte |
REMOVED
Status indicator for removed table entries.
|
Constructor and Description |
---|
OpenIntToSet()
Build an empty map with default size and using zero for missing entries.
|
OpenIntToSet(int expectedSize)
Build an empty map with specified size.
|
OpenIntToSet(OpenIntToSet<T> source)
Copy constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
containsEntry(int key,
T value) |
boolean |
containsKey(int key)
Check if a value is associated with a key.
|
java.util.Set<T> |
get(int key)
Get the stored value associated with the given key
|
java.util.Set<T>[] |
getValues() |
boolean |
isEmpty() |
OpenIntToSet.Iterator |
iterator()
Get an iterator over map elements.
|
void |
put(int key,
T value)
Put a value associated with a key in the map.
|
java.util.Set<T> |
remove(int key)
Remove the value associated with a key.
|
boolean |
remove(int key,
T value) |
int |
size()
Get the number of elements stored in the map.
|
protected static final byte FREE
protected static final byte FULL
protected static final byte REMOVED
public OpenIntToSet()
public OpenIntToSet(int expectedSize)
expectedSize
- expected number of elements in the mappublic OpenIntToSet(OpenIntToSet<T> source)
source
- map to copypublic java.util.Set<T> get(int key)
key
- key associated with the datapublic boolean containsKey(int key)
key
- key to checkpublic OpenIntToSet.Iterator iterator()
The specialized iterators returned are fail-fast: they throw a
ConcurrentModificationException
when they detect the map has
been modified during iteration.
public int size()
public boolean isEmpty()
public java.util.Set<T> remove(int key)
key
- key to which the value is associatedpublic boolean containsEntry(int key, T value)
public boolean remove(int key, T value)
public void put(int key, T value)
key
- key to which value is associatedvalue
- value to put in the mappublic java.util.Set<T>[] getValues()