This question was initially erroneous, see EDIT below. I will leave this for context.
I was thinking of smart ways to build a bijective (i.e., one-to-one) mapping. Displaying the function A-> B (many-to-one) is basically what HashMap (A, B) does. If I wanted to have a data structure that implements something individually with contains () in O (1), would there be something in the standard java libraries that I could use? Keep in mind that I don’t need it for anything right now, it was what I was thinking about recently and could not think of a data structure, so the answers are in no hurry. Is there such a class? If not, what do you think, why is this?
All I could find in SO were things about hibernation, it didn't help me.
EDIT: My question was hacked, so the explanation is being explained.
What I had in mind was the “reverse” mapping B-> A. HashMap (A, B) contains (A) and contains (B) as in O (1), so it’s not even what I had in mind sorry for the confusion. What I had in mind was: Is there a data structure mapping A ↔ B that has getValue (A) and getKey (B) in O (1)?
I understand that this can be done with two HashMaps (A, B) and (B, A) that are supported with the same ratio, but I feel that there should be one data structure that processes this without doing it “manually” .
G. bach
source share