Does anyone know if it is possible to keep a TreeMap sorted in cases where I update one of my keys properties?
Lets suppose my key is sorted by property 'a', while b is used on equals():
class Key implements Comparable<Key> {
int a;
int b;
// compareTo, equals end hashcode here
}
When key/value pairs are added, they will be sorted in a TreeMap, however how could I make sure the TreeMap will keep them sorted if I update one of these keys (property a)?