Java 中是否有 STL-Multiset 等效容器?
我仍在寻找理想的解决方案 这个问题。总而言之,我正在使用 Java 对电源子系统进行建模,并且需要一个用于数据的有向无环图 (DAG) 类型容器。
我在 C++ 的标准模板库 (STL) 中找到了我所需要的内容。它是multiset,它支持为同一键存储多个数据值。我可以清楚地看到如何使用此数据结构来存储电源节点和密钥及其上游/下游连接作为值。
我的客户有一个硬性要求,要求我用 Java 编写电源子系统模型,因此我需要一个与 STL 多重集相同的数据结构。我可能会自己推出,但现在已经晚了,我不能承担犯错误的风险。
我对 Java 对树/图集合的关注如此之少感到非常失望。
有人在Java中发现了多重集类型的结构吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
查看 Guava 的 Multiset。特别是 HashMultiset 和 TreeMultiset。
Check out Guava's Multiset. In particular the HashMultiset and the TreeMultiset.
您是否看过 Google 的版本:http: //google-collections.googlecode.com/svn/trunk/javadoc/com/google/common/collect/Multiset.html
Have you looked at Google's version: http://google-collections.googlecode.com/svn/trunk/javadoc/com/google/common/collect/Multiset.html