|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
A representation of a Map
with value-type Integer
,
supporting a variety of additional operations.
The sum of two IntegerMap
s is defined as a map on the
union of the keys. If a key is contained in both maps, it is mapped
to the sum of the two original values, otherwise to its unique original
value.
The multiplication of an IntegerMap
with an integer i is
defined to be the multiplication of each value with i.
Nested Class Summary |
Nested classes inherited from class java.util.Map |
java.util.Map.Entry |
Method Summary | |
void |
add(IntegerMap map)
Adds another IntegerMap to this map, by adding each entry
using add(Object, int) . |
void |
add(java.lang.Object key,
int value)
Adds the specified value to the value already stored for the specified key. |
void |
addMultiple(IntegerMap map,
int factor)
Adds a multiple of another IntegerMap to this map,
which is (almost) equivalent to add(map.multiply(factor)),
except that the other map remains unchanged. |
boolean |
isZero()
Checks, if every value is zero (or null) |
void |
multiply(int value)
Multiplies each value of this map by a common factor |
java.lang.Object |
put(java.lang.Object key)
An equivalent to put(key,1) |
java.lang.Object |
put(java.lang.Object key,
int value)
Associates the specified (int) value with the specified key in this map. |
int |
value(java.lang.Object key)
Returns the value to which this map maps the specified key. |
Methods inherited from interface java.util.Map |
clear, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, put, putAll, remove, size, values |
Method Detail |
public java.lang.Object put(java.lang.Object key, int value)
key
- the key with which the specified value is to be associatedvalue
- the integer value
public java.lang.Object put(java.lang.Object key)
put(key,1)
key
- the key to be entered into the map (with value 1)
public void multiply(int value)
value
- the factor, which is to be multiplied to each valuepublic void add(java.lang.Object key, int value)
put(key, value)
key
- the key whose value should be changedvalue
- the increment of the valuepublic void add(IntegerMap map)
IntegerMap
to this map, by adding each entry
using add(Object, int)
.
map
- the IntegerMap
to be addedpublic int value(java.lang.Object key)
key
- the key whose value should be returned
Map.get(Object)
public void addMultiple(IntegerMap map, int factor)
IntegerMap
to this map,
which is (almost) equivalent to add(map.multiply(factor)),
except that the other map remains unchanged.
map
- the map to be addedfactor
- the factor which is multiplied to the map, before adding it.public boolean isZero()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |