Performance: Creating an ArrayList from HashMap.values()

后端 未结 5 718
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-12 10:58

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条回答
  •  闹比i
    闹比i (楼主)
    2021-02-12 11:21

    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.

提交回复
热议问题