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()
AbstractCloneableSerializable
Object
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 CloneableSerializable
clone
in class AbstractCloneableSerializable
public java.util.Map<KeyType,NumberType> asMap()
ScalarMap
java.util.Map
that contains the same data as in this
scalar map.public void setAll(java.lang.Iterable<? extends KeyType> keys, double value)
ScalarMap
public void setAll(ScalarMap<? extends KeyType> other)
ScalarMap
public double increment(KeyType key)
ScalarMap
public double increment(KeyType key, double value)
ScalarMap
public void incrementAll(java.lang.Iterable<? extends KeyType> keys)
ScalarMap
incrementAll
in interface ScalarMap<KeyType>
keys
- A list of keys.public void incrementAll(ScalarMap<? extends KeyType> other)
ScalarMap
incrementAll
in interface ScalarMap<KeyType>
other
- The other map.public double decrement(KeyType key)
ScalarMap
public double decrement(KeyType key, double value)
ScalarMap
public void decrementAll(java.lang.Iterable<? extends KeyType> keys)
ScalarMap
decrementAll
in interface ScalarMap<KeyType>
keys
- A list of keys.public void decrementAll(ScalarMap<? extends KeyType> other)
ScalarMap
decrementAll
in interface ScalarMap<KeyType>
other
- The other map.public double getMaxValue()
ScalarMap
getMaxValue
in interface ScalarMap<KeyType>
public double getMinValue()
ScalarMap
getMinValue
in interface ScalarMap<KeyType>
public boolean isEmpty()
NumericMap
isEmpty
in interface NumericMap<KeyType>
public KeyType getMaxValueKey()
NumericMap
getMaxValueKey
in interface NumericMap<KeyType>
public java.util.Set<KeyType> getMaxValueKeys()
NumericMap
getMaxValueKeys
in interface NumericMap<KeyType>
public KeyType getMinValueKey()
NumericMap
getMinValueKey
in interface NumericMap<KeyType>
public java.util.Set<KeyType> getMinValueKeys()
NumericMap
getMinValueKeys
in interface NumericMap<KeyType>
public void clear()
NumericMap
clear
in interface NumericMap<KeyType>
public java.util.Set<KeyType> keySet()
NumericMap
keySet
in interface NumericMap<KeyType>
public boolean containsKey(KeyType key)
NumericMap
containsKey
in interface NumericMap<KeyType>
key
- A key.public int size()
NumericMap
size
in interface NumericMap<KeyType>