I have two lists with two different type of objects each, List list1 and List list2. The object at position i in list1 is related with that at position i in list2.
I have to answer queries of the type, given an object A return the object B at the same position in list2, and viceversa, given an object B return the object A at the same position in list1.
The trivial solution would be an O(n) search for each query. I'm looking for possible solutions to improve it. So far, what I have are two dictionaries, one Dictionary<A, B> dicAtoB and Dictionary<B, A> dicBtoA where I inserted all the elements from the lists in each of them. I'm asking for some other solutions as in mine the elements are inserted twice, and I have to use this two extra dictionaries and...I don't know what else but I just don't like mine to much.