Package org.apache.commons.math3.util
Class OpenIntToDoubleHashMap
java.lang.Object
org.apache.commons.math3.util.OpenIntToDoubleHashMap
- All Implemented Interfaces:
Serializable
Open addressed map from int to double.
This class provides a dedicated map from integers to doubles 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.
- Since:
- 2.0
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassIterator class for the map. -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionBuild an empty map with default size and using NaN for missing entries.OpenIntToDoubleHashMap(double missingEntries) Build an empty map with default sizeOpenIntToDoubleHashMap(int expectedSize) Build an empty map with specified size and using NaN for missing entries.OpenIntToDoubleHashMap(int expectedSize, double missingEntries) Build an empty map with specified size.Copy constructor. -
Method Summary
Modifier and TypeMethodDescriptionbooleancontainsKey(int key) Check if a value is associated with a key.doubleget(int key) Get the stored value associated with the given keyiterator()Get an iterator over map elements.doubleput(int key, double value) Put a value associated with a key in the map.doubleremove(int key) Remove the value associated with a key.intsize()Get the number of elements stored in the map.
-
Field Details
-
FREE
Status indicator for free table entries.- See Also:
-
FULL
Status indicator for full table entries.- See Also:
-
REMOVED
Status indicator for removed table entries.- See Also:
-
-
Constructor Details
-
OpenIntToDoubleHashMap
public OpenIntToDoubleHashMap()Build an empty map with default size and using NaN for missing entries. -
OpenIntToDoubleHashMap
Build an empty map with default size- Parameters:
missingEntries- value to return when a missing entry is fetched
-
OpenIntToDoubleHashMap
Build an empty map with specified size and using NaN for missing entries.- Parameters:
expectedSize- expected number of elements in the map
-
OpenIntToDoubleHashMap
Build an empty map with specified size.- Parameters:
expectedSize- expected number of elements in the mapmissingEntries- value to return when a missing entry is fetched
-
OpenIntToDoubleHashMap
Copy constructor.- Parameters:
source- map to copy
-
-
Method Details
-
get
Get the stored value associated with the given key- Parameters:
key- key associated with the data- Returns:
- data associated with the key
-
containsKey
Check if a value is associated with a key.- Parameters:
key- key to check- Returns:
- true if a value is associated with key
-
iterator
Get an iterator over map elements.The specialized iterators returned are fail-fast: they throw a
ConcurrentModificationExceptionwhen they detect the map has been modified during iteration.- Returns:
- iterator over the map elements
-
size
Get the number of elements stored in the map.- Returns:
- number of elements stored in the map
-
remove
Remove the value associated with a key.- Parameters:
key- key to which the value is associated- Returns:
- removed value
-
put
Put a value associated with a key in the map.- Parameters:
key- key to which value is associatedvalue- value to put in the map- Returns:
- previous value associated with the key
-