views:

476

answers:

2

I have two sets of objects where in some cases the first set will be used as keys for the other set, and in other cases the second set will be used as keys for the first. In addition there must be no duplicates in either list.

What would be a good data-structure to use for this? Should I use two Dictionaries for this or are there smarter ways?

+3  A: 

Someone with better knowledge of data structures could probably give better advice, but personally, I'd use 2 dictionaries for ease of use. You could do the same with 1 dictionary but access time would increase.

Edit: crap, I was just in the process of writing up some code how I would do it and I saw that Falaina posted this which is the same idea that I was doing only much better: http://stackoverflow.com/questions/255341/getting-key-of-value-of-a-generic-dictionary/255638#255638

Dinah
O, nice. Will accept this as the answer in this question then :)
Svish
+1  A: 

There are a few multikey collections out there. Try:

http://powercollections.codeplex.com/

or

http://www.codeproject.com/KB/recipes/multikey-dictionary.aspx

Wintellect's power collections are probably a great place to start. They have a tested MultiDictioanry as part of their package.

Paul Sasik