Let's suppose we want to associate to some set of distinct values a key, and suppose the mapping is injective. I want to be able to do things, and do them as quickly as possible: get the key of a given value and get the value corresponding to a give key. However, if possible I'd like to do key retrieval in O(1).
There are multiple ways to store key, value pairs in Java, for example with dictionaries or hashmaps. But neither is perfect: for example neither structure has a method for retrieving a key from a given value. My values are positive integer pairs. It might just be better to store the keys in a matrix so I can retrieve them immediately.
For my needs, what is the best option?