问题
Is there any Java library with TreeMap-like data structure which also supports all of these:
- lookup by value (like Guava's BiMap)
- possibility of non-unique keys as well as non unique values (like Guava's Multimap)
- keeps track of sorted values as well as sorted keys
If it exists, it would probaby be called SortedBiTreeMultimap, or similar :)
This can be produced using a few data structures together, but I never took time to unite them in one nice class, so I was wondering if someone else has done it already.
回答1:
I think you are looking for a "Graph". You might be interested in this slightly similar question asked a while ago, as well as this discussion thread on BiMultimaps / Graphs. Google has a BiMultimap in its internal code base, but they haven't yet decided whether to open source it.
来源:https://stackoverflow.com/questions/7909581/sortedbitreemultimap-data-structure-in-java