|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.util.AbstractMap<E,Double>
com.aliasi.util.SmallObjectToDoubleMap<E>
public class SmallObjectToDoubleMap<E extends Comparable<E>>
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.
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.
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).
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.
| Constructor Summary | |
|---|---|
SmallObjectToDoubleMap(Map<E,? extends Number> map)
Construct a small object to double map from the specified map. |
|
| Method Summary | |
|---|---|
boolean |
containsKey(Object key)
|
boolean |
containsValue(Object value)
|
double |
dotProduct(SmallObjectToDoubleMap<E> that)
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()
|
Double |
get(Object key)
|
double |
getValue(E key)
Returns the value of the specified key as a primitive double value. |
boolean |
isEmpty()
|
SmallObjectToDoubleMap<E> |
multiply(double x)
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()
|
| 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 |
|---|
public SmallObjectToDoubleMap(Map<E,? extends Number> map)
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.
map - Map from which to construct the small object to
double map.| Method Detail |
|---|
public double getValue(E key)
0.0 is returned.
key - Key whose value is returned.
public Set<Map.Entry<E,Double>> entrySet()
entrySet in interface Map<E extends Comparable<E>,Double>entrySet in class AbstractMap<E extends Comparable<E>,Double>public boolean containsKey(Object key)
containsKey in interface Map<E extends Comparable<E>,Double>containsKey in class AbstractMap<E extends Comparable<E>,Double>public boolean containsValue(Object value)
containsValue in interface Map<E extends Comparable<E>,Double>containsValue in class AbstractMap<E extends Comparable<E>,Double>public Double get(Object key)
get in interface Map<E extends Comparable<E>,Double>get in class AbstractMap<E extends Comparable<E>,Double>public int size()
size in interface Map<E extends Comparable<E>,Double>size in class AbstractMap<E extends Comparable<E>,Double>public boolean isEmpty()
isEmpty in interface Map<E extends Comparable<E>,Double>isEmpty in class AbstractMap<E extends Comparable<E>,Double>public double dotProduct(SmallObjectToDoubleMap<E> that)
The definition of dot product in this case is:
dotprod(map1,map2) = Σe map1.getValue(e) * map2.getValue(e)
that - Map to multiply with this one.
public SmallObjectToDoubleMap<E> multiply(double x)
x - Value to multiply each entry by.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||