Performance: Creating an ArrayList from HashMap.values()

后端 未结 5 1392
感动是毒
感动是毒 2021-02-12 10:32

Question is how much it costs to create an ArrayList from a HashMap.values() Collection? Or creating the values Collection alone? Assuming Map.size() > 100k. Objects could also

5条回答
  •  無奈伤痛
    2021-02-12 11:06

    You can create Your own HashMap, that holds the Arraylist collection of values directly (i do not believe that HashMap does it for free, the data structure for it is different). But this requires some additional coding from Your side.

提交回复
热议问题