RFR: 8186958: Need method to create pre-sized HashMap [v10]

liach duke at openjdk.java.net
Tue Apr 5 23:20:44 UTC 2022


On Sat, 2 Apr 2022 22:46:19 GMT, XenoAmess <duke at openjdk.java.net> wrote:

>> 8186958: Need method to create pre-sized HashMap
>
> XenoAmess has updated the pull request incrementally with one additional commit since the last revision:
> 
>   revert changes in jdk.compile

src/java.base/share/classes/java/util/LinkedHashMap.java line 804:

> 802:      * @since 19
> 803:      */
> 804:     public static <K, V> LinkedHashMap<K, V> newLinkedHashMap(int numMappings) {

`LinkedHashMap` may be often extended for it has a `protected boolean removeEldestEntry(Entry)`. Should we make a separate factory method for such instances (with functional implementation) or just expose `HashMap.calculateHashMapCapacity`?

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

PR: https://git.openjdk.java.net/jdk/pull/7928


More information about the core-libs-dev mailing list