Using Hashtable, no. But instead, you can use TreeMap .
Red-Ebony NavigableMap . The card is sorted in accordance with the natural order of its keys or the comparator, provided the card is created, depending on which constructor is used.
It has a firstKey() method that provides the exact functionality you want. C>
Grr, values, not keys. No, then you will need to iterate.
I would say that in this case you should use a separate card (Multimap?) To store feedback.
Map<Object, Integer> hash= new Hashtable<Object, Integer>(); SortedSetMultimap<Integer, Object> reverse = TreeMultimap.create();
whenever you put key , value something in hash , also put value , key in reverse . then get the lowest value using reverse.keySet().first()
( Guava is required for this solution)
source share