I’m migrating some code over to GNU trove for performance reasons.
However, I do have some TreeSets, where I need rather fast update and lookups along with a sorted iteration – the primary use case of a TreeSet. Of course I will go over the use and check if I can maybe live with a HashSet just as good.
What is the appropriate replacement from GNU Trove for a SortedSet?
Thank you.
Update: I found a related feature request in Trove on Sourceforge: http://sourceforge.net/tracker/index.php?func=detail&aid=1631704&group_id=39235&atid=424685
There doesn’t seem to be a SortedSet so far, and the benefits of Trove seem to be less big here: it will save some memory for primitive types (and avoid boxing), but the algorithmic organization of the data will likely be the same, and it will still need entry objects.
Update #2:
For many use cases – depending on your write access patterns -, you should be able to get a decent performance by just using a
TIntArrayListand using thebinarySearchmethod for lookup (which assumes the array to be sorted!)Inserting into a sorted array is O(n), so this is not an option when you perform a ton of modifications to the array, and query after each. But if your changes are bulk additions, just calling
sortafter each update should give you a surprisingly good performance!