tags:

views:

108

answers:

1

I want to temporary store some mapping data. The mapping is one to one. I saw this was solved in Python by wrapping two dictionaries in one class. In this case the O for getting mapped value would be O(1). I wan't the same thing. Does .Net already have such structure or I have to implement my own with two dictionaries?

+4  A: 

You have to implement it using two dictionaries. There's no built-in type in the base class library that efficiently supports indexing both by key and value.

Mehrdad Afshari
I am not sure if author wants indexing by both key and value.
SolutionYogi
I can infer that from the need of *two dictionaries in Python*.
Mehrdad Afshari
Well, if dataset is small, he can simply write a method to do lookup by value.
SolutionYogi
If the data set was small he should not have worried about Big-Oh.
Mehrdad Afshari
Well, that's true. If he wants O(1) solution, he would need two dictionaries.
SolutionYogi
Yes, I want both key and value indexed and it should be fast too. I guess there is no built in structure if nobody has mentioned it then?
Sergej Andrejev
Trust me. There isn't. If you're still not convinced, just check out the list of collections yourself. They are all in the "System.Collections" namespace.
Mehrdad Afshari