RFR: 8266571: Sequenced Collections [v4]

Tagir F. Valeev tvaleev at openjdk.org
Thu Mar 30 09:56:42 UTC 2023


On Fri, 24 Mar 2023 21:39:09 GMT, Tagir F. Valeev <tvaleev at openjdk.org> wrote:

>> Stuart Marks has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Simplify handling of cached keySet, values, and entrySet views.
>
> src/java.base/share/classes/java/util/LinkedHashMap.java line 1197:
> 
>> 1195: 
>> 1196:         public V computeIfAbsent(K key, Function<? super K, ? extends V> mappingFunction) {
>> 1197:             return base.computeIfAbsent(key, mappingFunction);
> 
> Again, it's somewhat worrysome that methods like `computeIfAbsent` will actually add new nodes to the end of original LinkedHashMap instead of to the beginning. Probably not very big deal but looks inconsistent...

Likely, for the first iteration it's possible to remove specializations for compute*/merge methods and use the default implementation from the `Map` interface, which will properly insert the new item to the beginning (if we properly implement reversed `put`). Later it could be optimized if necessary. What do you think?

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/7387#discussion_r1153015878


More information about the core-libs-dev mailing list