The code currently in withAll on both mutable and immutable implementations calls toArray on IntStream which if the Stream is very large can be extremely expensive and won't take advantage of a Bag's ability to store duplicates as simply increments in a count.
Current mutable factory code:
public MutableIntBag withAll(IntStream items)
{
return this.with(items.toArray());
}
Current immutable factory code:
public ImmutableIntBag withAll(IntStream items)
{
return this.with(items.toArray());
}
It would be much better to simply iterate over the Stream and add the results to a HashBag, converting to an ImmutableBag in the immutable factory.