jsat.utils
Class IntDoubleMap
- java.lang.Object
-
- java.util.AbstractMap<java.lang.Integer,java.lang.Double>
-
- jsat.utils.IntDoubleMap
-
- All Implemented Interfaces:
- java.util.Map<java.lang.Integer,java.lang.Double>
public final class IntDoubleMap extends java.util.AbstractMap<java.lang.Integer,java.lang.Double>A hash map for storing the primitive types of integers (as keys) to doubles (as table). The implementation is based on Algorithm D (Open addressing with double hashing) from Knuth's TAOCP page 528.
-
-
Nested Class Summary
-
Constructor Summary
Constructors Constructor and Description IntDoubleMap()IntDoubleMap(int capacity)IntDoubleMap(int capacity, float loadFactor)IntDoubleMap(java.util.Map<java.lang.Integer,java.lang.Double> collection)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidclear()booleancontainsKey(int key)booleancontainsKey(java.lang.Object key)java.util.Set<java.util.Map.Entry<java.lang.Integer,java.lang.Double>>entrySet()doubleget(int key)Returns the value to which the specified key is mapped, orDouble.NaNif this map contains no mapping for the key.java.lang.Doubleget(java.lang.Object key)int[]getRawKeyTable()byte[]getRawStatusTable()double[]getRawValueTable()static inth(int key)Returns a non-negative hash valuedoubleincrement(int key, double delta)doubleput(int key, double value)java.lang.Doubleput(java.lang.Integer key, java.lang.Double value)doubleremove(int key)java.lang.Doubleremove(java.lang.Object key)intsize()
-
-
-
Constructor Detail
-
IntDoubleMap
public IntDoubleMap()
-
IntDoubleMap
public IntDoubleMap(int capacity)
-
IntDoubleMap
public IntDoubleMap(java.util.Map<java.lang.Integer,java.lang.Double> collection)
-
IntDoubleMap
public IntDoubleMap(int capacity, float loadFactor)
-
-
Method Detail
-
size
public int size()
- Specified by:
sizein interfacejava.util.Map<java.lang.Integer,java.lang.Double>- Overrides:
sizein classjava.util.AbstractMap<java.lang.Integer,java.lang.Double>
-
getRawKeyTable
public int[] getRawKeyTable()
-
getRawValueTable
public double[] getRawValueTable()
-
getRawStatusTable
public byte[] getRawStatusTable()
-
put
public java.lang.Double put(java.lang.Integer key, java.lang.Double value)- Specified by:
putin interfacejava.util.Map<java.lang.Integer,java.lang.Double>- Overrides:
putin classjava.util.AbstractMap<java.lang.Integer,java.lang.Double>
-
put
public double put(int key, double value)
-
increment
public double increment(int key, double delta)- Parameters:
key- the key whose associated value is to be incremented. All non-present keys behave as having an implicit value of zero, in which case the delta value is directly inserted into the map.delta- the amount by which to increment the key's stored value.- Returns:
- the new value stored for the given key
-
get
public double get(int key)
Returns the value to which the specified key is mapped, orDouble.NaNif this map contains no mapping for the key.- Parameters:
key- the key whose associated value is to be returned- Returns:
- the value to which the specified key is mapped, or
Double.NaNif this map contains no mapping for the key
-
get
public java.lang.Double get(java.lang.Object key)
- Specified by:
getin interfacejava.util.Map<java.lang.Integer,java.lang.Double>- Overrides:
getin classjava.util.AbstractMap<java.lang.Integer,java.lang.Double>
-
remove
public java.lang.Double remove(java.lang.Object key)
- Specified by:
removein interfacejava.util.Map<java.lang.Integer,java.lang.Double>- Overrides:
removein classjava.util.AbstractMap<java.lang.Integer,java.lang.Double>
-
remove
public double remove(int key)
- Parameters:
key-- Returns:
- the old value stored for this key, or
Double.NaNif the key was not present in the map
-
clear
public void clear()
- Specified by:
clearin interfacejava.util.Map<java.lang.Integer,java.lang.Double>- Overrides:
clearin classjava.util.AbstractMap<java.lang.Integer,java.lang.Double>
-
containsKey
public boolean containsKey(java.lang.Object key)
- Specified by:
containsKeyin interfacejava.util.Map<java.lang.Integer,java.lang.Double>- Overrides:
containsKeyin classjava.util.AbstractMap<java.lang.Integer,java.lang.Double>
-
containsKey
public boolean containsKey(int key)
-
h
public static int h(int key)
Returns a non-negative hash value- Parameters:
key-- Returns:
-
entrySet
public java.util.Set<java.util.Map.Entry<java.lang.Integer,java.lang.Double>> entrySet()
- Specified by:
entrySetin interfacejava.util.Map<java.lang.Integer,java.lang.Double>- Specified by:
entrySetin classjava.util.AbstractMap<java.lang.Integer,java.lang.Double>
-
-
DataMelt 3.0 © DataMelt by jWork.ORG