T
- the type of the elementspublic class OpenIntToList<T>
extends java.lang.Object
implements java.io.Serializable
This class provides a dedicated map from integers to Lists with a much smaller memory overhead than standard
java.util.Map
.
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 |
OpenIntToList.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 |
---|
OpenIntToList()
Build an empty map with default size and using zero for missing entries.
|
OpenIntToList(int expectedSize)
Build an empty map with specified size.
|
OpenIntToList(OpenIntToList<T> source)
Copy constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
containsKey(int key)
Check if a value is associated with a key.
|
java.util.List<T> |
get(int key)
Get the stored value associated with the given key
|
boolean |
isEmpty() |
OpenIntToList.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.List<T> |
remove(int key)
Remove the value associated with a key.
|
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 OpenIntToList()
public OpenIntToList(int expectedSize)
expectedSize
- expected number of elements in the mappublic OpenIntToList(OpenIntToList<T> source)
source
- map to copypublic java.util.List<T> get(int key)
key
- key associated with the datapublic boolean containsKey(int key)
key
- key to checkpublic OpenIntToList.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.List<T> remove(int key)
key
- key to which the value is associatedpublic void put(int key, T value)
key
- key to which value is associatedvalue
- value to put in the map