RFR: 8266571: Sequenced Collections [v3]
Stuart Marks
smarks at openjdk.org
Tue Mar 28 01:31:45 UTC 2023
On Fri, 24 Mar 2023 21:35:22 GMT, Tagir F. Valeev <tvaleev at openjdk.org> wrote:
>> Stuart Marks has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 78 commits:
>>
>> - Merge branch 'master' into JDK-8266571-SequencedCollections
>> - Update copyrights.
>> - More specification tweaks.
>> - Add simple overrides to ArrayList.
>> - Specification cleanups.
>> - Update spec of CopyOnWriteArrayList::reversed.
>> - Move AbstractViewCollection to AbstractMap.ViewCollection to avoid exposing it publicly.
>> - Merge branch 'master' into JDK-8266571-SequencedCollections
>> Resolve conflict by deleting IdentityLinkedList.java
>> - Merge branch 'master' into JDK-8266571-SequencedCollections
>> - Fix indentation.
>> - ... and 68 more: https://git.openjdk.org/jdk/compare/6aec6f3a...91c4eabe
>
> src/java.base/share/classes/java/util/LinkedHashMap.java line 1123:
>
>> 1121:
>> 1122: public V put(K key, V value) {
>> 1123: return base.put(key, value);
>
> Why `put()` simply delegates to `base.put()` while `putAll()` below does more complex containsKey-put-putFirst procedure? I think that `putAll()` should be equivalent to `for(var e : m.entrySet()) put(e.getKey(), e.getValue());`. Am I missing something?
I think you're right, you're not missing anything. The entry that is put() should always go at the end of this view, and since this is the reversed view, it should go at the front of the base map. And putAll() should follow.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/7387#discussion_r1149933611
More information about the core-libs-dev
mailing list