2

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?

Community
  • 1
  • 1
retrodrone
  • 5,850
  • 9
  • 39
  • 65
  • possible duplicate of [HashMap with multiple values under the same key](http://stackoverflow.com/questions/4956844/hashmap-with-multiple-values-under-the-same-key) – finnw Jun 08 '11 at 22:51

2 Answers2

8

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

Andrew White
  • 52,720
  • 19
  • 113
  • 137
  • [Multimap](http://guava-libraries.googlecode.com/svn/tags/release02/javadoc/com/google/common/collect/Multimap.html) is what I'm really looking for. Many thanks! – retrodrone Jun 08 '11 at 23:12
1

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

Jack Edmonds
  • 31,931
  • 18
  • 65
  • 77
  • 3
    Google Collections is [deprecated](http://code.google.com/p/google-collections/). Use [Guava](http://code.google.com/p/guava-libraries/) instead. – finnw Jun 08 '11 at 22:46