Package components.map
Interface Map<K,V>
- Type Parameters:
K
- type ofMap
domain (key) entriesV
- type ofMap
range (associated value) entries
- All Known Implementing Classes:
Map1L
,Map2
,Map3
,Map4
,MapSecondary
MapKernel
enhanced with secondary methods.- Mathematical Definitions:
RANGE( m: PARTIAL_FUNCTION ): finite set of V satisfies for all value: V (value is in RANGE(m) iff there exists key: K ((key, value) is in m))
-
Nested Class Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
combineWith
(Map<K, V> m) Combinesm
withthis
.boolean
Reports whether there is a pair inthis
whose second component isvalue
.Reports a key associated withvalue
inthis
.replaceValue
(K key, V value) Replaces the value associated withkey
inthis
withvalue
and returns the old value.boolean
sharesKeyWith
(Map<K, V> m) Reports whetherthis
andm
have any keys in common.Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
Methods inherited from interface components.map.MapKernel
add, hasKey, remove, removeAny, size, value
Methods inherited from interface components.standard.Standard
clear, newInstance, transferFrom
-
Method Details
-
replaceValue
Replaces the value associated withkey
inthis
withvalue
and returns the old value.- Parameters:
key
- the key whose associated value is replacedvalue
- the value replacing the old one- Returns:
- the old value associated with the given key
- Aliases:
- reference
value
- Updates:
this
- Requires:
key is in DOMAIN(this)
- Ensures:
this = (#this \ {(key, replaceValue)}) union {(key, value)} and (key, replaceValue) is in #this
-
key
Reports a key associated withvalue
inthis
. Note that the key returned generally should not be changed at all via this aliased reference, and if it is then it definitely must not be changed in such a way that it equals another key in the map from which it was obtained.- Parameters:
value
- the value whose associated key is to be reported- Returns:
- a key associated with value
- Aliases:
- reference returned by
key
- Requires:
value is in RANGE(this)
- Ensures:
(key, value) is in this
-
hasValue
Reports whether there is a pair inthis
whose second component isvalue
.- Parameters:
value
- the value to be checked- Returns:
- true iff there is a pair in
this
whose second component isvalue
- Ensures:
hasValue = (value is in RANGE(this))
-
combineWith
Combinesm
withthis
.- Parameters:
m
- theMap
to be combined withthis
- Updates:
this
- Clears:
m
- Requires:
DOMAIN(this) intersection DOMAIN(m) = {}
- Ensures:
this = #this union #m
-