-
Enhancement
-
Resolution: Unresolved
-
P4
-
None
-
None
When collecting elements from a stream it is not possible for the stream pipeline to inform the collecting supplier of known size when requesting a new mutable result container.
For example, if the exact size of the stream pipeline is known and results are collected concurrently into a concurrent hash map, then that map can be pre-sized thus ensuring concurrent updates will likely be more efficient as there is less chance of resizes occurring.
The new method could be:
default IntFunction<A> sizedSupplier() {
return i -> supplier().get();
}
A -1 can be passed to the sized supplying function if the exact size is not known.
For example, if the exact size of the stream pipeline is known and results are collected concurrently into a concurrent hash map, then that map can be pre-sized thus ensuring concurrent updates will likely be more efficient as there is less chance of resizes occurring.
The new method could be:
default IntFunction<A> sizedSupplier() {
return i -> supplier().get();
}
A -1 can be passed to the sized supplying function if the exact size is not known.