it.unimi.dsi.fastutil.shorts
Interface Short2DoubleMap

All Superinterfaces:
Map
All Known Subinterfaces:
Short2DoubleSortedMap
All Known Implementing Classes:
AbstractShort2DoubleMap, AbstractShort2DoubleSortedMap, Short2DoubleAVLTreeMap, Short2DoubleLinkedOpenHashMap, Short2DoubleMaps.SynchronizedMap, Short2DoubleMaps.UnmodifiableMap, Short2DoubleOpenHashMap, Short2DoubleRBTreeMap, Short2DoubleSortedMaps.EmptySortedMap, Short2DoubleSortedMaps.Singleton, Short2DoubleSortedMaps.SynchronizedSortedMap, Short2DoubleSortedMaps.UnmodifiableSortedMap

public interface Short2DoubleMap
extends Map

A type-specific Map; provides some additional methods that use polymorphism to reduce type juggling, and handling of a default return value.

Type-specific versions of get(), put() and remove() cannot rely on null to denote absence of a key. Rather, they return a default return value, which is set to 0 cast to the return type (false for booleans) at creation, but can be changed using the defaultReturnValue() method.

For uniformity reasons, even maps returning objects implement the default return value (of course, in this case the default return value is initialized to null). This very useful for maps containing null keys.

A submap or subset may or may not have an independent default return value (which however must be initialized to the default return value of the originator).

Warning: to fall in line as much as possible with the standard map interface, it is strongly suggested that standard versions of get(), put() and remove() for maps with primitive-type values return null to denote missing keys rather than wrap the default return value in an object (of course, for maps with object keys and values this is not possible, as there is no type-specific version).

See Also:
Map

Nested Class Summary
static interface Short2DoubleMap.Entry
          A type-specific Map.Entry; provides some additional methods to access its content reducing type juggling.
 
Method Summary
 boolean containsKey(short key)
           
 boolean containsValue(double value)
           
 double defaultReturnValue()
          Gets the default return value.
 void defaultReturnValue(double rv)
          Sets the default return value.
 double get(short key)
          Returns the value to which the given key is mapped.
 double getDefRetValue()
          Deprecated. As of fastutil 2.0, replaced by defaultReturnValue().
 double put(short key, double value)
          Adds a pair to the map.
 double remove(short key)
          Removes the mapping with the given key.
 void setDefRetValue(double rv)
          Deprecated. As of fastutil 2.0, replaced by defaultReturnValue().
 
Methods inherited from interface java.util.Map
clear, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, put, putAll, remove, size, values
 

Method Detail

put

public double put(short key,
                  double value)
Adds a pair to the map.

Parameters:
key - the key.
value - the value.
Returns:
the old value, or the default return value if no value was present for the given key.
See Also:
Map.put(Object,Object)

get

public double get(short key)
Returns the value to which the given key is mapped.

Parameters:
key - the key.
Returns:
the corresponding value, or the default return value if no value was present for the given key.
See Also:
Map.get(Object)

remove

public double remove(short key)
Removes the mapping with the given key.

Parameters:
key -
Returns:
the old value, or the default return value if no value was present for the given key.
See Also:
Map.remove(Object)

containsKey

public boolean containsKey(short key)
See Also:
Map.containsKey(Object)

containsValue

public boolean containsValue(double value)
See Also:
Map.containsValue(Object)

setDefRetValue

public void setDefRetValue(double rv)
Deprecated. As of fastutil 2.0, replaced by defaultReturnValue().

Parameters:
rv - the new default return value.
See Also:
getDefRetValue(), defaultReturnValue()

getDefRetValue

public double getDefRetValue()
Deprecated. As of fastutil 2.0, replaced by defaultReturnValue().

Returns:
the current default return value.
See Also:
defaultReturnValue()

defaultReturnValue

public void defaultReturnValue(double rv)
Sets the default return value. This value must be returned by type-specific versions of get(), put() and remove() to denote that the map does not contain the specified key. It must be 0/false/null by default.

Parameters:
rv - the new default return value.
See Also:
defaultReturnValue()

defaultReturnValue

public double defaultReturnValue()
Gets the default return value.

Returns:
the current default return value.