Package org.apache.commons.math.util
Class OpenIntToFieldHashMap<T extends FieldElement<T>>
- java.lang.Object
-
- org.apache.commons.math.util.OpenIntToFieldHashMap<T>
-
- Type Parameters:
T
- the type of the field elements
- All Implemented Interfaces:
java.io.Serializable
public class OpenIntToFieldHashMap<T extends FieldElement<T>> extends java.lang.Object implements java.io.Serializable
Open addressed map from int to FieldElement.This class provides a dedicated map from integers to FieldElements 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 aConcurrentModificationException
when they detect the map has been modified during iteration.- Since:
- 2.0
- Version:
- $Revision: 990655 $ $Date: 2010-08-29 23:49:40 +0200 (dim. 29 août 2010) $
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
OpenIntToFieldHashMap.Iterator
Iterator class for the map.
-
Constructor Summary
Constructors Constructor Description OpenIntToFieldHashMap(Field<T> field)
Build an empty map with default size and using zero for missing entries.OpenIntToFieldHashMap(Field<T> field, int expectedSize)
Build an empty map with specified size and using zero for missing entries.OpenIntToFieldHashMap(Field<T> field, int expectedSize, T missingEntries)
Build an empty map with specified size.OpenIntToFieldHashMap(Field<T> field, T missingEntries)
Build an empty map with default sizeOpenIntToFieldHashMap(OpenIntToFieldHashMap<T> source)
Copy constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
containsKey(int key)
Check if a value is associated with a key.T
get(int key)
Get the stored value associated with the given keyOpenIntToFieldHashMap.Iterator
iterator()
Get an iterator over map elements.T
put(int key, T value)
Put a value associated with a key in the map.T
remove(int key)
Remove the value associated with a key.int
size()
Get the number of elements stored in the map.
-
-
-
Field Detail
-
FREE
protected static final byte FREE
Status indicator for free table entries.- See Also:
- Constant Field Values
-
FULL
protected static final byte FULL
Status indicator for full table entries.- See Also:
- Constant Field Values
-
REMOVED
protected static final byte REMOVED
Status indicator for removed table entries.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
OpenIntToFieldHashMap
public OpenIntToFieldHashMap(Field<T> field)
Build an empty map with default size and using zero for missing entries.- Parameters:
field
- field to which the elements belong
-
OpenIntToFieldHashMap
public OpenIntToFieldHashMap(Field<T> field, T missingEntries)
Build an empty map with default size- Parameters:
field
- field to which the elements belongmissingEntries
- value to return when a missing entry is fetched
-
OpenIntToFieldHashMap
public OpenIntToFieldHashMap(Field<T> field, int expectedSize)
Build an empty map with specified size and using zero for missing entries.- Parameters:
field
- field to which the elements belongexpectedSize
- expected number of elements in the map
-
OpenIntToFieldHashMap
public OpenIntToFieldHashMap(Field<T> field, int expectedSize, T missingEntries)
Build an empty map with specified size.- Parameters:
field
- field to which the elements belongexpectedSize
- expected number of elements in the mapmissingEntries
- value to return when a missing entry is fetched
-
OpenIntToFieldHashMap
public OpenIntToFieldHashMap(OpenIntToFieldHashMap<T> source)
Copy constructor.- Parameters:
source
- map to copy
-
-
Method Detail
-
get
public T get(int key)
Get the stored value associated with the given key- Parameters:
key
- key associated with the data- Returns:
- data associated with the key
-
containsKey
public boolean containsKey(int key)
Check if a value is associated with a key.- Parameters:
key
- key to check- Returns:
- true if a value is associated with key
-
iterator
public OpenIntToFieldHashMap.Iterator iterator()
Get an iterator over map elements.The specialized iterators returned are fail-fast: they throw a
ConcurrentModificationException
when they detect the map has been modified during iteration.- Returns:
- iterator over the map elements
-
size
public int size()
Get the number of elements stored in the map.- Returns:
- number of elements stored in the map
-
remove
public T remove(int key)
Remove the value associated with a key.- Parameters:
key
- key to which the value is associated- Returns:
- removed value
-
-