Is there an STL-Multiset equivalent container in Java?

穿精又带淫゛_ 提交于 2019-12-13 15:31:47

问题


I'm still seeking an ideal solution to this question. To summarize, I am modeling a power subsystem in Java and I need a Directed-Acyclic-Graph (DAG)-type container for my data.

I found exactly what I need in C++'s Standard Template Library (STL). It is the multiset, which supports storing multiple data values for the same key. I can clearly see how storing power nodes and keys, and their upstream/downstream connections as values, could be pulled off with this data structure.

My customer has a hard-requirement that I write the power subsystem model in Java, so I need a data structure identical to the STL multiset. I could potentially roll my own, but it's late in the game and I can't afford the risk of making a mistake.

I'm supremely disappointed that Java is so light on Tree / Graph collections.

Has anyone found an multiset-type structure in Java?


回答1:


Check out Guava's Multiset. In particular the HashMultiset and the TreeMultiset.




回答2:


Have you looked at Google's version: http://google-collections.googlecode.com/svn/trunk/javadoc/com/google/common/collect/Multiset.html



来源:https://stackoverflow.com/questions/6285941/is-there-an-stl-multiset-equivalent-container-in-java

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