0

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?

3
  • @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 Commented 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. Commented 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. Commented Oct 3, 2016 at 13:31

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.