Package components.map
Interface Map<K,V>
- Type Parameters:
K- type ofMapdomain (key) entriesV- type ofMaprange (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
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionvoidcombineWith(Map<K, V> m) Combinesmwiththis.booleanReports whether there is a pair inthiswhose second component isvalue.Reports a key associated withvalueinthis.replaceValue(K key, V value) Replaces the value associated withkeyinthiswithvalueand returns the old value.booleansharesKeyWith(Map<K, V> m) Reports whetherthisandmhave any keys in common.Methods inherited from interface java.lang.Iterable
forEach, iterator, spliteratorMethods inherited from interface components.map.MapKernel
add, hasKey, remove, removeAny, size, valueMethods inherited from interface components.standard.Standard
clear, newInstance, transferFrom
-
Method Details
-
replaceValue
Replaces the value associated withkeyinthiswithvalueand 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 withvalueinthis. 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 inthiswhose second component isvalue.- Parameters:
value- the value to be checked- Returns:
- true iff there is a pair in
thiswhose second component isvalue - Ensures:
hasValue = (value is in RANGE(this))
-
combineWith
Combinesmwiththis.- Parameters:
m- theMapto be combined withthis- Updates:
this- Clears:
m- Requires:
DOMAIN(this) intersection DOMAIN(m) = {}- Ensures:
this = #this union #m
-