com.aliasi.util
Class SmallObjectToDoubleMap<E extends Comparable<E>>

java.lang.Object
  extended by java.util.AbstractMap<E,Double>
      extended by com.aliasi.util.SmallObjectToDoubleMap<E>
Type Parameters:
E - the type of comparable keys for the map
All Implemented Interfaces:
Serializable, Map<E,Double>

Deprecated. Use plain ObjectToDoubleMap.

@Deprecated
public class SmallObjectToDoubleMap<E extends Comparable<E>>
extends AbstractMap<E,Double>
implements Serializable

A SmallObjectToDoubleMap provides a space-efficient implementation of an immutable map from objects to doubles. The map is constructed using any mapping from objects to doubles, such as a HashMap or a ObjectToDoubleMap.

Key Comparability

Keys in the map are required to implement the Comparable interface. If two keys are equal under the comparability interface, the behavior of the get method is undefined. This is because Arrays.binarySearch(Object[],Object) is used to look up keys rather than hash codes. It is not strictly necessary for the keys to implement equality and hash codes consistently with their comparability for this class.

Sparse Vector Method

Like ObjectToDoubleMap, there is a getValue(Comparable) method which is defined to return 0.0 if the specified key does not exist under the mapping. Mathematically, this makes the map a sparse vector in the dimensionality of the number of possible key objects (usually infinite).

Serialization

An instance of SmallObjectToDoubleMap may be serialized if its keys may be serialized. If the keys are not serializable, writing the object to an object output stream will throw an exception.

Since:
LingPipe3.1
Version:
3.8.3
Author:
Bob Carpenter
See Also:
Serialized Form

Constructor Summary
SmallObjectToDoubleMap(Map<E,? extends Number> map)
          Deprecated. Construct a small object to double map from the specified map.
 
Method Summary
 boolean containsKey(Object key)
          Deprecated.  
 boolean containsValue(Object value)
          Deprecated.  
 double dotProduct(SmallObjectToDoubleMap<E> that)
          Deprecated. Returns the vector dot product of this map with the specified map, taking the keys to be the dimensions.
 Set<Map.Entry<E,Double>> entrySet()
          Deprecated.  
 Double get(Object key)
          Deprecated.  
 double getValue(E key)
          Deprecated. Returns the value of the specified key as a primitive double value.
 boolean isEmpty()
          Deprecated.  
 SmallObjectToDoubleMap<E> multiply(double x)
          Deprecated. Returns a new map which has the same keys as this map with values equal to the ones in this map multiplied by the specified value.
 int size()
          Deprecated.  
 
Methods inherited from class java.util.AbstractMap
clear, clone, equals, hashCode, keySet, put, putAll, remove, toString, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SmallObjectToDoubleMap

public SmallObjectToDoubleMap(Map<E,? extends Number> map)
Deprecated. 
Construct a small object to double map from the specified map. The numbers in the specified map's values will be converted to double-precision floating point (double) values before being stored.

Copies are made of all values, so changes to the specified map will not affect this map or vice-versa.

Parameters:
map - Map from which to construct the small object to double map.
Method Detail

getValue

public double getValue(E key)
Deprecated. 
Returns the value of the specified key as a primitive double value. If the key is not defined in the map, the value 0.0 is returned.

Parameters:
key - Key whose value is returned.
Returns:
Value for specified key as a primitive double.

entrySet

public Set<Map.Entry<E,Double>> entrySet()
Deprecated. 
Specified by:
entrySet in interface Map<E extends Comparable<E>,Double>
Specified by:
entrySet in class AbstractMap<E extends Comparable<E>,Double>

containsKey

public boolean containsKey(Object key)
Deprecated. 
Specified by:
containsKey in interface Map<E extends Comparable<E>,Double>
Overrides:
containsKey in class AbstractMap<E extends Comparable<E>,Double>

containsValue

public boolean containsValue(Object value)
Deprecated. 
Specified by:
containsValue in interface Map<E extends Comparable<E>,Double>
Overrides:
containsValue in class AbstractMap<E extends Comparable<E>,Double>

get

public Double get(Object key)
Deprecated. 
Specified by:
get in interface Map<E extends Comparable<E>,Double>
Overrides:
get in class AbstractMap<E extends Comparable<E>,Double>

size

public int size()
Deprecated. 
Specified by:
size in interface Map<E extends Comparable<E>,Double>
Overrides:
size in class AbstractMap<E extends Comparable<E>,Double>

isEmpty

public boolean isEmpty()
Deprecated. 
Specified by:
isEmpty in interface Map<E extends Comparable<E>,Double>
Overrides:
isEmpty in class AbstractMap<E extends Comparable<E>,Double>

dotProduct

public double dotProduct(SmallObjectToDoubleMap<E> that)
Deprecated. 
Returns the vector dot product of this map with the specified map, taking the keys to be the dimensions.

The definition of dot product in this case is:

 dotprod(map1,map2) = Σe map1.getValue(e) * map2.getValue(e)
 

Parameters:
that - Map to multiply with this one.
Returns:
The dot product between this map and the specified one.

multiply

public SmallObjectToDoubleMap<E> multiply(double x)
Deprecated. 
Returns a new map which has the same keys as this map with values equal to the ones in this map multiplied by the specified value.

Parameters:
x - Value to multiply each entry by.
Returns:
Scaled map.