I'm trying find a structure similar to a LinkedHashMap that sorts it by its value. I'll need to be able to update the values. I'll be checking the order very often, so I need a solution that avoids sorting the Map every time.
something like this:
DynamicSortedMap<String,Integer> map = new DynamicSortedMap<String,Integer>();
map.put("key1",4);
map.put("key2",3);
map.put("key3",6);
System.out.println("Map: "+map);
map.update("key1",1);
System.out.println("Update:"+map);
Output:
Map: {key3=6, key1=4, key2=3}
Update: {key3=6, key2=3, key1=1}
Is there any stucture that allows this? If not, any ideas of how to do it?
Thanks for your help,