为什么在java集合框架中没有直接实现Bag? [英] Why is there no direct implemention of Bag in java collection framework?

查看:1588
本文介绍了为什么在java集合框架中没有直接实现Bag?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道为什么JCF(Java Collection Framework)没有Bag实现(允许重复和不维护顺序)。
在JCF中,包的性能会比当前集合的实现好多了。




  • 我知道如何在java中实现Bag。 li>
  • 我知道Apache中有一个Bag集合。

  • 我知道我可以使用任何实现作为包!



为什么Java Collections框架没有提供像这样的直接实现? / p>

解决方案

将我的评论发布为答案,因为它最能回答这个问题。



此处提交的错误报告:



Collection框架的维护者设计和实现这些接口/类没有太多的热情。
我个人不记得需要一个。更有可能的是
,在JDK之外开发的一个流行包将被证明在现实世界中的价值后,将
导入JDK。


今天对支持Bag的需求是有效的。



Guava 支持它。另外 GS-Collections 。 / p>

I can't figure out why JCF (Java Collection Framework) does't have a Bag implementation(to allow duplicates and not maintain order). Bag performance would be much better than current Collection implementations in JCF.

  • I know how to implement Bag in java.
  • I know there is a Bag collection in Apache common.
  • I know i can use any implementation as a bag! but there are so much work in other implementations compare to Bag.

Why has the Java Collections framework not provided direct implementations like this?

解决方案

Posting my comment as an answer since it answers this question best.

From the bug report filed here :

There isn't a lot of enthusiasm among the maintainers of the Collection framework to design and implement these interfaces/classes. I personally can't recall having needed one. It would be more likely that a popular package developed outside the JDK would be imported into the JDK after having proved its worth in the real world.

The need for having support for Bags is valid today.

Guava has support for it. Also GS-Collections.

这篇关于为什么在java集合框架中没有直接实现Bag?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆