双向字典吗? [英] Bi-directional dictionary?

查看:601
本文介绍了双向字典吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两组对象,其中在一些情况下,第一组将被用作用于其它键组,而在其他情况下,第二组将被用作用于第一密钥。此外,必须有任一列表中没有重复。

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?

推荐答案

有人用数据结构,更好的知识也许可以提供更好的意见但就个人而言,我会使用2字典对于易用性。你可以做同样的1本字典,而是访问时间将增加

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.

修改:废话,我只是在写一些过程代码中,我会怎么做,我看到Falaina张贴了这个这是我做的只是要好得多了同样的想法:的 http://stackoverflow.com/questions/255341/getting-key-of-value-of-a-generic-dictionary/255638#255638

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

这篇关于双向字典吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆