Are there any Java libraries that have a sorted Map
(such as TreeMap
) but has the ability to replace keys
? For example I'm looking for something that could replace treeMapInstance.firstKey()
. Speed is reasonably important which is why I'm not one for storing values, deleting, then placing values back in a new key.
In my application I may have an object such as
TreeMap<Long, Double> foo = new TreeMap<Long, Double>();
Sometimes I would like to change a key in foo
without altering the associated value.
foo.put(1l, 1.0);
foo.put(2l, 2.0);
In the above for example how could I change the key
1l
to 5l
efficiently?