A
Andreas Leitgeb
Given a (Hash)Map<Long,Long> map and two Long values k and v,
Some task is to see if k is already in the map, and only if so,
then update the value in the map based on previous value and v.
Of course, that is trivial, and I've already implemented
it with containsKey(), get() and put().
It's just, that it seems to me that my piece of code
could be a bit *clearer*, if I could obtain the Map.Entry
for "k", and (if that isn't null) do getValue() and
setValue(...) on the Entry.
What I'm missing, however, is:
How would I get the Entry for a given key?
(apart from scanning all through the entrySet())
PS: using 1.6, but also interested in future (i.e. 1.7 or
even newer) prospects, and also in (any) explicit reasons
for *not* having some map.getEntry(K k).
Also, such an Entry should be tied to the Map just like
those in the entrySet(). NavigableMap has methods that
return Entries with "snapshot"-semantics, which is *not*
what I'm looking for.
Some task is to see if k is already in the map, and only if so,
then update the value in the map based on previous value and v.
Of course, that is trivial, and I've already implemented
it with containsKey(), get() and put().
It's just, that it seems to me that my piece of code
could be a bit *clearer*, if I could obtain the Map.Entry
for "k", and (if that isn't null) do getValue() and
setValue(...) on the Entry.
What I'm missing, however, is:
How would I get the Entry for a given key?
(apart from scanning all through the entrySet())
PS: using 1.6, but also interested in future (i.e. 1.7 or
even newer) prospects, and also in (any) explicit reasons
for *not* having some map.getEntry(K k).
Also, such an Entry should be tied to the Map just like
those in the entrySet(). NavigableMap has methods that
return Entries with "snapshot"-semantics, which is *not*
what I'm looking for.