表示两个或多个因素之间的直接或反向关系的最佳 Guava (Google) 集合 API 是什么?
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.
Thanks in advance.
Prakash
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您能否展示一个简单的代码示例来说明如何使用这种数据结构?
键/值应该是唯一的吗?在这种情况下,BiMap 听起来不错。
如果键/值不唯一,您需要某种“BiMultimap”(也称为“图表”),如本 番石榴讨论线程。 Google 还没有开源他们自己的内部 BiMultimap。
如果您想要图表,您可能需要查看 JUNG 或 Flexigraph,如帖子中所述。
Could you show a simple code sample of how you would use such a data structure?
Should keys / values be unique? In this case, BiMap sounds about right.
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.
If you want a graph, you might want to look at JUNG or Flexigraph, as discussed in the thread.