I have the following two classes:
class KeyClass { private prop1; private prop2; hashcode() { //implemented properly } equals() { //implemented properly } } class ValueClass { private prop1; private prop2; hashcode() { //implemented properly } equals() { //implemented properly } }
I am trying to figure out the maximum pair from a map, where the objects of these classes are respectively key and value pairs. I also have com.google.common.collect.Ordering<ValueClass> that uses multiple comparators. I can easily find out the maximum values ββusing this ordering, but I'm interested in the maximum value key.
I can write a specific implementation in which I can track my key by value in a loop and use ordering to compare values ββ(similar to the usual methods of finding the maximum value), but I want to know if we already have such a case, Guava or any other library?
source share