tschuchort
01/03/2018, 12:30 PMMap
entry without iterating over the whole entry set? I need it to be able to change the associated value of a key repeatedly without having to find the key in the map again every time.diesieben07
01/03/2018, 12:31 PMMutableMap
are mutable and have a setValue
method.diesieben07
01/03/2018, 12:32 PMval myEntry = myMap.entries.find { it.key == myKey }
myEntry.setValue(newValue)
diesieben07
01/03/2018, 12:33 PMdiesieben07
01/03/2018, 12:33 PMmarstran
01/03/2018, 12:36 PMmyMap[key] = firstValue
...
myMap[key] = secondValue
Or do you have to change the actual entry?diesieben07
01/03/2018, 12:36 PMmarstran
01/03/2018, 12:37 PMAndreas Sinz
01/03/2018, 12:50 PMsnrostov
01/03/2018, 1:04 PMkarelpeeters
01/03/2018, 1:27 PMkarelpeeters
01/03/2018, 1:27 PMkarelpeeters
01/03/2018, 1:30 PMMap
and Map.Entry
require that entries stay connected to the map, no?tschuchort
01/03/2018, 1:53 PMsnrostov
01/03/2018, 2:11 PMNo, javadocs says:require that entries stay connected to the map, no?Map.Entry
* These <tt>Map.Entry</tt> objects are
* valid <i>only</i> for the duration of the iteration; more formally,
* the behavior of a map entry is undefined if the backing map has been
* modified after the entry was returned by the iterator, except through
* the <tt>setValue</tt> operation on the map entry.