List with Comparable Vs TreeSet
问题 Option 1: Make a list which implements Comparable and sort it using collections.sort(List l) every time you add a value. Option 2: Make a TreeSet (which keeps itself sorted all the time). Which one will be faster? I am asking this because List gives me the option of ListIterator which I need in my case, since it lets me add an element while iterating. 回答1: The most important differences: Criterion | List with Collections.sort | TreeSet ----------------+----------------------------+---------