If I have a HashMap<KEY, VALUE>
and I need fast look up of the key by the value is there any other approach besides creating a second HashMap<VALUE, KEY>
that store the same data but using the value as the key?
Is there any approach/tick about this? If it makes a difference my interest is about String
both as key and value
Note: I am on Java 7
Update:
I am not sure why the other question is a duplicate as I am asking a specific way on implementing this.
Unless the only/best way is a 2 way map I can't see why this is a duplicate