A good Sorted List for Java

后端 未结 10 1703
离开以前
离开以前 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:59

    It seems that you want a list structure with very fast removal and random access by index (not by key) times. An ArrayList gives you the latter and a HashMap or TreeMap give you the former.

    There is one structure in Apache Commons Collections that may be what you are looking for, the TreeList. The JavaDoc specifies that it is optimized for quick insertion and removal at any index in the list. If you also need generics though, this will not help you.

提交回复
热议问题