What is the best Guava (Google) collection API to

2020-04-11 10:44发布

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

标签: java guava bimap
1条回答
别忘想泡老子
2楼-- · 2020-04-11 11:42

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.

查看更多
登录 后发表回答