I think your choices are
- Use a map implementation built for this, like the BiMap from google collections. Note that the google collections BiMap requires uniqueless of values, as well as keys, but it provides high performance in both directions performance
- Manually maintain two maps - one for key -> value, and another map for value -> key
- Iterate through the
entrySet()
and to find the keys which match the value. This is the slowest method, since it requires iterating through the entire collection, while the other two methods don't require that.