SortedSet for integers with GNU trove

I am porting some code to GNU for performance reasons.

However, I have some TreeSets where I need a fairly quick update and search along with sorted iteration - the main use case for TreeSet. Of course, I will go over to use and check if I can live with a HashSet just as well.

What is a suitable replacement for GNU Trove for SortedSet?

Thanks.

+4
source share
1 answer

Update: I found a related function request in Trove on Sourceforge: http://sourceforge.net/tracker/index.php?func=detail&aid=1631704&group_id=39235&atid=424685

So far, there is no SortedSet, and the advantages of Trove seem less significant here: it will save some memory for primitive types (and avoid boxing), but the algorithmic organization of the data will most likely be the same, and it will still need input objects.

Update # 2:

For many use cases - depending on your write access patterns - you should have decent performance just by using the TIntArrayList and using the binarySearch method to search (which involves sorting the array!)

Insertion into the sorted array is O (n), so this is not an option when you perform a ton of changes in the array and query after each. But if your changes are voluminous additions, just calling sort after each update will give you amazingly good performance!

+2
source

Source: https://habr.com/ru/post/1382542/


All Articles