I have a HashMap. When i add elements to the hashmap, i want them to be automatically sorted according to the Double value. I don't want to sort the whole map every 10 seconds because it lowers the performance of the program. Any ideas?
-
@Tunaki the example you marked as duplicate has an already defined map with values. my values are changed/added every 10 seconds. and after the command sortedData.putAll(unsortedData); if i type sortedData.put(newKey,new Value) the new value isnt sortedc_user89– c_user892016-10-03 13:23:46 +00:00Commented Oct 3, 2016 at 13:23
-
That would be another question. This one asks for a way to automatically sort a map with regard to its values, and the linked question answers that. If you have an issue implementing it, make sure you research the problem, make a minimal reproducible example and post a new question with what you have.Tunaki– Tunaki2016-10-03 13:26:40 +00:00Commented Oct 3, 2016 at 13:26
-
@Tunaki my english is bad and it was the best way for me to ask the question. and i have been googling it for 2 working days. The SortedSet solves my problem. But i cant retrieve the value according to the key with get. so SortedSet doesnt suite me.c_user89– c_user892016-10-03 13:31:56 +00:00Commented Oct 3, 2016 at 13:31
Add a comment
|