RFR: 8186958: Need method to create pre-sized HashMap

XenoAmess duke at openjdk.java.net
Thu Mar 24 00:43:56 UTC 2022


On Wed, 23 Mar 2022 21:26:02 GMT, liach <duke at openjdk.java.net> wrote:

>> 8186958: Need method to create pre-sized HashMap
>
> src/java.base/share/classes/java/util/Collections.java line 5826:
> 
>> 5824:      * @since 19
>> 5825:      */
>> 5826:     public static <K, V> HashMap<K, V> newHashMap(int expectedSize) {
> 
> Stuart [in a JBS comment](https://bugs.openjdk.java.net/browse/JDK-8186958?focusedCommentId=14483078&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-14483078) recommends keeping these factories to the respective classes instead of `Collections`. In existing code, such factories stay in the respective classes, including `ConcurrentHashMap.newKeySet(int)`.
> 
> Since this is an API change, I suggest you determine where the methods will stay before filing a CSR request.

good but I have no account to comment on your jira system.

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

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


More information about the core-libs-dev mailing list