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
2009-07-04 19:47:27
I am not sure if author wants indexing by both key and value.
SolutionYogi
2009-07-04 19:49:20
I can infer that from the need of *two dictionaries in Python*.
Mehrdad Afshari
2009-07-04 19:50:11
Well, if dataset is small, he can simply write a method to do lookup by value.
SolutionYogi
2009-07-04 19:52:21
If the data set was small he should not have worried about Big-Oh.
Mehrdad Afshari
2009-07-04 19:53:36
Well, that's true. If he wants O(1) solution, he would need two dictionaries.
SolutionYogi
2009-07-04 19:55:15
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
2009-07-04 20:13:27
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
2009-07-04 20:23:48