java bag,为什么在java集合框架中没有直接实现Bag?

博客探讨了Java集合框架(JCF)中缺少Bag接口实现的原因,指出Bag允许重复元素且不维护顺序,其性能优于现有实现。尽管Apache Commons提供了Bag集合,但作者认为JCF直接内置Bag会更方便。文章引用了一个bug报告,说明JCF维护者对该功能缺乏热情,通常会等待外部库经过实战验证后再引入到JDK。Guava和GS-Collections等库已支持Bag概念。
摘要由CSDN通过智能技术生成

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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值