Package repast.simphony.util.collections
Class OpenLongToDoubleHashMap
- java.lang.Object
-
- repast.simphony.util.collections.OpenLongToDoubleHashMap
-
- All Implemented Interfaces:
Serializable
public class OpenLongToDoubleHashMap extends Object implements Serializable
Open addressed map from long to double. Modified version of the original Apache Math3 OpenIntToDoubleHashMap.This class provides a dedicated map from longs 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 aConcurrentModificationException
when they detect the map has been modified during iteration.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
OpenLongToDoubleHashMap.Iterator
Iterator class for the map.
-
Constructor Summary
Constructors Constructor Description OpenLongToDoubleHashMap()
Build an empty map with default size and using NaN for missing entries.OpenLongToDoubleHashMap(double missingEntries)
Build an empty map with default sizeOpenLongToDoubleHashMap(int expectedSize)
Build an empty map with specified size and using NaN for missing entries.OpenLongToDoubleHashMap(int expectedSize, double missingEntries)
Build an empty map with specified size.OpenLongToDoubleHashMap(OpenLongToDoubleHashMap source)
Copy constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
containsKey(long key)
Check if a value is associated with a key.double
get(long key)
Get the stored value associated with the given keyOpenLongToDoubleHashMap.Iterator
iterator()
Get an iterator over map elements.double
put(long key, double value)
Put a value associated with a key in the map.double
remove(long 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
-
OpenLongToDoubleHashMap
public OpenLongToDoubleHashMap()
Build an empty map with default size and using NaN for missing entries.
-
OpenLongToDoubleHashMap
public OpenLongToDoubleHashMap(double missingEntries)
Build an empty map with default size- Parameters:
missingEntries
- value to return when a missing entry is fetched
-
OpenLongToDoubleHashMap
public OpenLongToDoubleHashMap(int expectedSize)
Build an empty map with specified size and using NaN for missing entries.- Parameters:
expectedSize
- expected number of elements in the map
-
OpenLongToDoubleHashMap
public OpenLongToDoubleHashMap(int expectedSize, double missingEntries)
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
-
OpenLongToDoubleHashMap
public OpenLongToDoubleHashMap(OpenLongToDoubleHashMap source)
Copy constructor.- Parameters:
source
- map to copy
-
-
Method Detail
-
get
public double get(long 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(long 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 OpenLongToDoubleHashMap.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 double remove(long key)
Remove the value associated with a key.- Parameters:
key
- key to which the value is associated- Returns:
- removed value
-
put
public double put(long key, double value)
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
-
-