问题
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