gov.sandia.cognition.collection
Interface ScalarMap<KeyType>

Type Parameters:
KeyType - The type of the key in the map.
All Superinterfaces:
NumericMap<KeyType>
All Known Subinterfaces:
DataDistribution<DataType>, DataDistribution.PMF<KeyType>, InfiniteVector<KeyType>
All Known Implementing Classes:
AbstractDataDistribution, AbstractMutableDoubleMap, AbstractScalarMap, DataCountTreeSetBinnedMapHistogram, DefaultDataDistribution, DefaultDataDistribution.PMF, DefaultInfiniteVector, ScalarDataDistribution, ScalarDataDistribution.CDF, ScalarDataDistribution.PMF

public interface ScalarMap<KeyType>
extends NumericMap<KeyType>

An interface for a mapping of objects to scalar values represented as doubles.

Since:
3.3.1
Author:
Justin Basilico

Nested Class Summary
static interface ScalarMap.Entry<KeyType>
          An entry in a scalar map.
 
Method Summary
 Map<KeyType,? extends Number> asMap()
          Gets a java.util.Map that contains the same data as in this scalar map.
 double decrement(KeyType key)
          Decrements the value associated with a given key by 1.0.
 double decrement(KeyType key, double value)
          Decrements the value associated with the given key by the given amount.
 void decrementAll(Iterable<? extends KeyType> keys)
          Decrements the values associated all of the given keys by 1.0.
 void decrementAll(ScalarMap<? extends KeyType> other)
          Decrements all the keys in this map by the values in the other one.
 Set<? extends ScalarMap.Entry<KeyType>> entrySet()
          Gets the set of entries in this scalar map.
 double get(KeyType key)
          Gets the value associated with a given key.
 double getMaxValue()
          The maximum value associated with any key in the map.
 double getMinValue()
          The minimum value associated with any key in the map.
 double increment(KeyType key)
          Increments the value associated with the given key by 1.0.
 double increment(KeyType key, double value)
          Increments the value associated with the given key by the given amount.
 void incrementAll(Iterable<? extends KeyType> keys)
          Increments the values associated all of the given keys by 1.0.
 void incrementAll(ScalarMap<? extends KeyType> other)
          Increments all the keys in this map by the values in the other one.
 void set(KeyType key, double value)
          Sets the value associated with a given key.
 void setAll(Iterable<? extends KeyType> keys, double value)
          Sets all the given keys to the given value.
 
Methods inherited from interface gov.sandia.cognition.collection.NumericMap
clear, containsKey, getMaxValueKey, getMaxValueKeys, getMinValueKey, getMinValueKeys, isEmpty, keySet, size
 

Method Detail

asMap

Map<KeyType,? extends Number> asMap()
Gets a java.util.Map that contains the same data as in this scalar map.

Returns:
The Map version of this data structure.

get

double get(KeyType key)
Gets the value associated with a given key. If the key does not exist, then 0.0 is returned.

Parameters:
key - A key.
Returns:
The value associated with the key or 0.0 if it does not exist.

set

void set(KeyType key,
         double value)
Sets the value associated with a given key. In some cases if the value is 0.0, the key may be removed from the map.

Parameters:
key - A key.
value - The value to associate with the key.

setAll

void setAll(Iterable<? extends KeyType> keys,
            double value)
Sets all the given keys to the given value.

Parameters:
keys - A list of keys.
value - The value to associate with all the given keys.

increment

double increment(KeyType key)
Increments the value associated with the given key by 1.0.

Parameters:
key - A key.
Returns:
The new value associated with the key.

increment

double increment(KeyType key,
                 double value)
Increments the value associated with the given key by the given amount.

Parameters:
key - A key.
value - The amount to increment the value associated with the given key by.
Returns:
The new value associated with the key.

incrementAll

void incrementAll(Iterable<? extends KeyType> keys)
Increments the values associated all of the given keys by 1.0.

Parameters:
keys - A list of keys.

incrementAll

void incrementAll(ScalarMap<? extends KeyType> other)
Increments all the keys in this map by the values in the other one.

Parameters:
other - The other map.

decrement

double decrement(KeyType key)
Decrements the value associated with a given key by 1.0.

Parameters:
key - A key.
Returns:
The new value associated with the key.

decrement

double decrement(KeyType key,
                 double value)
Decrements the value associated with the given key by the given amount.

Parameters:
key - A key.
value - The amount to decrement the value associated with the given key by.
Returns:
The new value associated with the key.

decrementAll

void decrementAll(Iterable<? extends KeyType> keys)
Decrements the values associated all of the given keys by 1.0.

Parameters:
keys - A list of keys.

decrementAll

void decrementAll(ScalarMap<? extends KeyType> other)
Decrements all the keys in this map by the values in the other one.

Parameters:
other - The other map.

getMaxValue

double getMaxValue()
The maximum value associated with any key in the map.

Returns:
The maximum value associated with any key in the map. If the map is empty, then Double.NEGATIVE_INFINITY is returned.

getMinValue

double getMinValue()
The minimum value associated with any key in the map.

Returns:
The minimum value associated with any key in the map. If the map is empty, then Double.POSITIVE_INFINITY is returned.

entrySet

Set<? extends ScalarMap.Entry<KeyType>> entrySet()
Gets the set of entries in this scalar map.

Returns:
The set of entries in the scalar map.