双向字典? [英] Bi-directional dictionary?
问题描述
这是一个很好的数据结构?我应该使用两个字典,还是有更智能的方式?
有更好的数据结构知识的人可能会提供更好的建议,但个人来说,我会使用2个字典来方便使用。你可以使用1个字典做同样的事情,但访问时间会增加。
编辑:废话,我正在写一些代码如何做,我看到Falaina发布了这是一样的想法,我只是做得更好:获取通用词典的价值的钥匙
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?
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: Getting key of value of a generic Dictionary?
这篇关于双向字典?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!