Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

13
  • 2
    +1 for binary search :).but if the OP uses an ArrayList, shifting after insertion would take time. A LinkedList would be more efficient in this case. Commented Jan 27, 2015 at 7:02
  • I don't know, you may be right. binarySearch is probably slower on LinkedList but insertion is faster... Commented Jan 27, 2015 at 7:05
  • 1
    @TheLostMind Just ran some tests, LinkedList performance is appalling for larg-ish samples (several minutes for 100k items), For smaller sizes (< 1000) it performs ok in absolute terms but still slower than ArrayList. Commented Jan 27, 2015 at 10:10
  • 1
    @TheLostMind It doesn't take so much time once you have jmh setup - probably 15 mins to write the code and then the test runs in background for 10 mins or so. Admittedly the first time I used it it took me a lot more than 15 mins to write my first real life test :-) Commented Jan 27, 2015 at 10:18
  • 1
    Wow, TreeMultiSet really shows all that Guava optimisation when you hit large numbers of items! Nine times faster is nothing to sniff at. Commented Jan 27, 2015 at 15:47