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?
Asked
Active
Viewed 33 times
0
-
@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 sorted – c_user89 Oct 03 '16 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 [mcve] and post a new question with what you have. – Tunaki Oct 03 '16 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 Oct 03 '16 at 13:31