What is the best Guava (Google) collection API to represent direct or inverse relationship between two or multiple factors?

别等时光非礼了梦想. 提交于 2019-12-02 00:35:59

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/5578029/what-is-the-best-guava-google-collection-api-to-represent-direct-or-inverse-re

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!