开发者

Is there an STL-Multiset equivalent container in Java?

开发者 https://www.devze.com 2023-03-11 04:36 出处:网络
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'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 开发者_StackOverflow中文版is so light on Tree / Graph collections.

Has anyone found an multiset-type structure in Java?


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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号