I would like to store a list of triplets of Enums- say List<<Enum1, Enum2, Enum3>>
where I should be able to look up by any of the fields. What I mean is, say I store something like,
List<<Enum1, Enum2, Enum3>> list;
list[0] = [ObjectOfEnum1, ObjectOfEnum2, ObjectOfEnum3]
list[1] = [ObjectOfEnum4, ObjectOfEnum5, ObjectOfEnum6]
list[2] = [ObjectOfEnum7, ObjectOfEnum8, ObjectOfEnum9]
list[3] = [ObjectOfEnum10, ObjectOfEnum11, ObjectOfEnum12]
.
.
I should be able to look up either by ObjectOfEnum5
to get list[1]
or by ObjectOfEnum1
to get list[0]
. I would like to get them in O(1). I am working with Java 8. Please point me to any data structure that could help me do this.
I can only think of having three Maps(each having a key of the different types of Enums) with the value of a tuple of the other 2. But this solution looks ugly. Please let me know if there is something I can use.