In Dart, I would like to implement two priority queues, one in ascending order and one in descending order.
The SDK class SplayTreeMap conveniently solves the ascending order case, i.e. I can use stm.values to get the values in ascending order. Is there a way to get SplayTreeMap to return the values in descending order? (apart from the obvious solution of sorting the values afterwards on every access). For example, is there a way to override the compare function of the value types?
Thanks in advance for any suggestions.
Answering my own question, just passing ‘inverse’ keys solved the problem (at least for my use case).