A good Sorted List for Java

后端 未结 10 1695
离开以前
离开以前 2020-11-30 02:29

I\'m looking for a good sorted list for java. Googling around give me some hints about using TreeSet/TreeMap. But these components is lack of one thing: random access to an

10条回答
  •  天命终不由人
    2020-11-30 02:54

    Depending on how you're using the list, it may be worth it to use a TreeSet and then use the toArray() method at the end. I had a case where I needed a sorted list, and I found that the TreeSet + toArray() was much faster than adding to an array and merge sorting at the end.

提交回复
热议问题