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.
Bag
in Java.Bag
is available in Apache commons.Bag
but there is so much work to do in other implementations compared to a 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.