javautils.maps
Class ObjectToDoubleMap

java.lang.Object
  |
  +--javautils.maps.AbstractTypedMap
        |
        +--javautils.maps.ObjectToDoubleMap
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable

public final class ObjectToDoubleMap
extends AbstractTypedMap

Map from objects to double-values. DoubleHolder-objects are used for storing the values in the map.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class javautils.maps.AbstractTypedMap
map
 
Constructor Summary
ObjectToDoubleMap()
          A new map based on the map type used by AbstractTypedMap.AbstractTypedMap(java.util.Map).
ObjectToDoubleMap(java.util.Map map)
          A new Object->double map using the given map.
 
Method Summary
 double get(java.lang.Object key)
          The value associated with the key - throws an assertion exception if the key is not associated with a value.
 double getOr(java.lang.Object key, double alternative)
          The value associated with the key or the specified alternative value if the key is not associated with any value.
 DoubleHolder holder(java.lang.Object key)
          The holder of the value associated with the key or null if the key is not associated with a value.
 void put(java.lang.Object key, double value)
          Associates the key with the specified value.
 void put(java.lang.Object key, DoubleHolder holder)
          Associates the key with the specified holder.
 DoubleHolder ref(java.lang.Object key)
          The holder associated with the key - throws an assertion exception if the key is not associated with a value.
 DoubleHolder refOr(java.lang.Object key, double value)
          The holder associated with the key or a new holder that holds the specified value and associated with the key.
protected  boolean valuePredicate(java.lang.Object value)
          Tests that the value is a non null DoubleHolder-object.
 
Methods inherited from class javautils.maps.AbstractTypedMap
clear, clone, containsKey, isEmpty, keyIterator, keySet, remove, size, toString, unmodifiableMap, valueIterator
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ObjectToDoubleMap

public ObjectToDoubleMap()

A new map based on the map type used by AbstractTypedMap.AbstractTypedMap(java.util.Map).


ObjectToDoubleMap

public ObjectToDoubleMap(java.util.Map map)

A new Object->double map using the given map. The given map must not contain any values that are not DoubleHolder-objects. The given map should also never be modified except by using the services of this class.

Method Detail

valuePredicate

protected boolean valuePredicate(java.lang.Object value)

Tests that the value is a non null DoubleHolder-object.

Specified by:
valuePredicate in class AbstractTypedMap

put

public void put(java.lang.Object key,
                double value)

Associates the key with the specified value. Will not create a new holder if the key is already associated with a value.


put

public void put(java.lang.Object key,
                DoubleHolder holder)

Associates the key with the specified holder.


get

public double get(java.lang.Object key)

The value associated with the key - throws an assertion exception if the key is not associated with a value.


getOr

public double getOr(java.lang.Object key,
                    double alternative)

The value associated with the key or the specified alternative value if the key is not associated with any value.


ref

public DoubleHolder ref(java.lang.Object key)

The holder associated with the key - throws an assertion exception if the key is not associated with a value.


refOr

public DoubleHolder refOr(java.lang.Object key,
                          double value)

The holder associated with the key or a new holder that holds the specified value and associated with the key.


holder

public DoubleHolder holder(java.lang.Object key)

The holder of the value associated with the key or null if the key is not associated with a value.