问题描述
BiMap确实具有逆方法,但是我不确定它是否适合用于此问题.有人可以建议替代方法或收集/方法吗?一个例子会有所帮助.
BiMap do have inverse method but I am not sure it is a right collection to use for the problem. Can someone please suggest alternative approach or collection/method? An example would be helpful.
先谢谢了.普拉卡什
推荐答案
您能显示一个简单的代码示例来说明如何使用这种数据结构吗?
Could you show a simple code sample of how you would use such a data structure?
键/值应该唯一吗?在这种情况下,BiMap听起来是正确的.
Should keys / values be unique? In this case, BiMap sounds about right.
如果键/值不是唯一的,则需要某种"BiMultimap"(也称为图形"),如本番石榴讨论线程. Google尚未(尚未?)开源自己的内部BiMultimap.
If keys / values are not unique, you want some kind of "BiMultimap" (also called a "graph"), as discussed in this Guava discussion thread. Google has not (yet?) open sourced their own internal BiMultimap.
如果需要图形,则可能需要查看 JUNG 或 Flexigraph .
If you want a graph, you might want to look at JUNG or Flexigraph, as discussed in the thread.
这篇关于代表两个或多个因素之间正向或反向关系的最佳Guava(Google)集合API是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!