Beruflich Dokumente
Kultur Dokumente
extends extends
MapKernel
extends
Map
implements implements
Map1L Map3
Map2
7 January 2019 OSU CSE 3
Interfaces and Classes
Standard Iterable
extends extends
Standard has contracts
for three methods: MapKernel
clear
newInstance extends
transferFrom
Map
implements implements
Map1L Map3
Map2
7 January 2019 OSU CSE 4
Interfaces and Classes
Standard Iterable
extends extends
MapKernel
MapKernel has contracts
for six methods: extends
add
remove Map
removeAny
implements implements
value
hasKey
Map1L Map3
size Map2
7 January 2019 OSU CSE 5
Interfaces
Map and Classes
has contracts for five
other Standard
methods: Iterable
replaceValue
key extends extends
hasValue
sharesKeyWith MapKernel
combineWith
extends
Map
implements implements
Map1L Map3
Map2
7 January 2019 OSU CSE 6
Interfaces and Classes
Standard Iterable
extends extends
Iterable has a contract
MapKernel
for one method:
iterator
extends
Map
implements implements
Map1L Map3
Map2
7 January 2019 OSU CSE 7
Mathematical Model
• The value of a Map variable is modeled as
a finite set of ordered pairs of type (K, V)
with “the function property”, i.e., no two
pairs in the set have the same K value
– This is sometimes called a (finite) partial
function from K to V
Map<String,Integer> m =
new Map1L<>();
Map<String,Integer> m =
new Map1L<>();
m = { }
m.add(k, v);
m.add(k, v);
m.add(k, v);
m = {("PB", 99),
("BW", 17),
("PS", 99)}
k = "PS"
v = 99
v = m.value(k);
v = m.value(k);
m = {("PB", 99),
("BW", 17)}
k = "PB"
v = 99
v = m.replaceValue(k, v);
v = m.replaceValue(k, v);
m = {("PB", 85),
("BW", 17)}
k = "PB"
v = 99
v = m.replaceValue(k, v);
m = {("PB", 85),
("BW", 17)}
k = "PB"
v = 99
k = m.key(v);
k = m.key(v);
m = {("PB", 99),
("BW", 17)}
k = "PB"
v = 99
k = m.key(v);
m = {("PB", 99),
("BW", 17)}
k = "PB"
v = 99
m1.combineWith(m2);
m1.combineWith(m2);
m1 = {("PB", 99),
("BW", 17),
("PS", 99)}
m2 = { }