Java Two-Way Linked Set data-structure [duplicate]

2019-06-26 02:35发布

问题:

This question already has an answer here:

  • Bidirectional multi-valued map in Java 6 answers

Is there an implementation of the following data-structure already implemented in Java:

Say I want the set for '2' ('A', 'C', 'D') but I also want the set for 'A' ('1', '2')

回答1:

You have no such data structure in the Java Collections Framework.

I suggest you the guava library you may find something useful there.

Note that what you have here is essentially a undirected graph so keep an eye out for graph libraries (for example JGraphT), or write your own.