ConcurrentSkipListSet and re-sorting (java)

I am using ConcurrentSkipListSet, which is obviously available across multiple threads. Now the values ​​used by the compareTo method for base objects change overtime. Because of this, I want to β€œupdate” the order of the list (by resorting to it, or something similar).

However, java.util.Collections.sort (list) does not work, and just rebuilding the list is probably too slow (and ruining all concurrency protection). Is there any other solution that I should pay attention to?

It should not lead to optimal sorting (which is almost impossible with concurrency and still change the values). Enough would be enough if any deletion / addition of calls remains thread safe (this would be a real problem when reinstalling the list during sorting).

+5
source share
2 answers

Each time you edit an element so that its sort order can potentially change, you must remove it from the list, then change the key, and then reinsert it.


Dr Cliff Click at Azul Systems , - .. skip-list/tree, - , , - op, . :)

+7

API Java (.. , compareTo). , - -, Will , .

HashSet : , set.contains( ... ), - .

, , ConcurrentSkipListSet HashSet, / . , "" , , (, ArrayList).

Set:

. , . , , , . , , .

SortedSet:

, , ( ), , Set. (. Comparable Comparator .) , Set , compareTo ( ), , , , . , ; Set.

+2

All Articles