There's nothing better than a LinkedHashMap vanilla LinkedHashMap , but here are a few alternatives with Guava ..
If you know that your values ββare unique, the BiMap API supports reverse lookups efficiently, without having to manually support reverse lookups. Use HashBiMap as your implementation, and you can search for a key from a value using bimap.inverse().get(value) .
If your values ββare not unique, you can create a Multimap that displays each value for each of the associated keys. You can do it fast using
Multimap<V, K> reverse = Multimaps.invertFrom( Multimaps.forMap(map), HashMultimap.<V, K> create());
which allows you to view all keys associated with a value using reverse.get(value) .
source share