KeyType - The type of the key in the Map.NumberType - the type of Number in the Map.public abstract class AbstractScalarMap<KeyType,NumberType extends java.lang.Number> extends AbstractCloneableSerializable implements ScalarMap<KeyType>
ScalarMap.Entry<KeyType>| Modifier and Type | Field and Description |
|---|---|
protected java.util.Map<KeyType,NumberType> |
map
Map backing that performs the storage.
|
| Constructor and Description |
|---|
AbstractScalarMap(java.util.Map<KeyType,NumberType> map)
Creates a new instance of AbstractScalarMap
|
| Modifier and Type | Method and Description |
|---|---|
java.util.Map<KeyType,NumberType> |
asMap()
Gets a
java.util.Map that contains the same data as in this
scalar map. |
void |
clear()
Removes all elements from the map.
|
AbstractScalarMap<KeyType,NumberType> |
clone()
This makes public the clone method on the
Object class and
removes the exception that it throws. |
boolean |
containsKey(KeyType key)
Determines if this map contains the given key.
|
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(java.lang.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.
|
double |
getMaxValue()
The maximum value associated with any key in the map.
|
KeyType |
getMaxValueKey()
Gets the non-unique key associated with the maximum value in the map.
|
java.util.Set<KeyType> |
getMaxValueKeys()
Gets a set of all keys associated with the maximum value in the map.
|
double |
getMinValue()
The minimum value associated with any key in the map.
|
KeyType |
getMinValueKey()
Gets the non-unique key associated with the minimum value in the map.
|
java.util.Set<KeyType> |
getMinValueKeys()
Gets a set of all keys associated with the minimum value 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(java.lang.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.
|
boolean |
isEmpty()
Returns true if the map is empty.
|
java.util.Set<KeyType> |
keySet()
Gets the set of unique keys in the map.
|
void |
setAll(java.lang.Iterable<? extends KeyType> keys,
double value)
Sets all the given keys to the given value.
|
void |
setAll(ScalarMap<? extends KeyType> other)
Sets all the given keys to the given value.
|
int |
size()
Gets the number of items in the map.
|
protected java.util.Map<KeyType,NumberType extends java.lang.Number> map
public AbstractScalarMap(java.util.Map<KeyType,NumberType> map)
map - The backing map that the data is stored in.public AbstractScalarMap<KeyType,NumberType> clone()
AbstractCloneableSerializableObject class and
removes the exception that it throws. Its default behavior is to
automatically create a clone of the exact type of object that the
clone is called on and to copy all primitives but to keep all references,
which means it is a shallow copy.
Extensions of this class may want to override this method (but call
super.clone() to implement a "smart copy". That is, to target
the most common use case for creating a copy of the object. Because of
the default behavior being a shallow copy, extending classes only need
to handle fields that need to have a deeper copy (or those that need to
be reset). Some of the methods in ObjectUtil may be helpful in
implementing a custom clone method.
Note: The contract of this method is that you must use
super.clone() as the basis for your implementation.clone in interface CloneableSerializableclone in class AbstractCloneableSerializablepublic java.util.Map<KeyType,NumberType> asMap()
ScalarMapjava.util.Map that contains the same data as in this
scalar map.public void setAll(java.lang.Iterable<? extends KeyType> keys, double value)
ScalarMappublic void setAll(ScalarMap<? extends KeyType> other)
ScalarMappublic double increment(KeyType key)
ScalarMappublic double increment(KeyType key, double value)
ScalarMappublic void incrementAll(java.lang.Iterable<? extends KeyType> keys)
ScalarMapincrementAll in interface ScalarMap<KeyType>keys - A list of keys.public void incrementAll(ScalarMap<? extends KeyType> other)
ScalarMapincrementAll in interface ScalarMap<KeyType>other - The other map.public double decrement(KeyType key)
ScalarMappublic double decrement(KeyType key, double value)
ScalarMappublic void decrementAll(java.lang.Iterable<? extends KeyType> keys)
ScalarMapdecrementAll in interface ScalarMap<KeyType>keys - A list of keys.public void decrementAll(ScalarMap<? extends KeyType> other)
ScalarMapdecrementAll in interface ScalarMap<KeyType>other - The other map.public double getMaxValue()
ScalarMapgetMaxValue in interface ScalarMap<KeyType>public double getMinValue()
ScalarMapgetMinValue in interface ScalarMap<KeyType>public boolean isEmpty()
NumericMapisEmpty in interface NumericMap<KeyType>public KeyType getMaxValueKey()
NumericMapgetMaxValueKey in interface NumericMap<KeyType>public java.util.Set<KeyType> getMaxValueKeys()
NumericMapgetMaxValueKeys in interface NumericMap<KeyType>public KeyType getMinValueKey()
NumericMapgetMinValueKey in interface NumericMap<KeyType>public java.util.Set<KeyType> getMinValueKeys()
NumericMapgetMinValueKeys in interface NumericMap<KeyType>public void clear()
NumericMapclear in interface NumericMap<KeyType>public java.util.Set<KeyType> keySet()
NumericMapkeySet in interface NumericMap<KeyType>public boolean containsKey(KeyType key)
NumericMapcontainsKey in interface NumericMap<KeyType>key - A key.public int size()
NumericMapsize in interface NumericMap<KeyType>