vigna / fastutil

fastutil extends the Java™ Collections Framework by providing type-specific maps, sets, lists and queues.
Apache License 2.0
1.8k stars 197 forks source link

Warn about preallocation collectors and parallel streams #212

Closed techsy730 closed 3 years ago

techsy730 commented 3 years ago

Per https://github.com/vigna/fastutil/issues/211, the toXWithExpectedSize collector methods will preallocate the full size for every worker thread when used on parallel streams. This is rather wasteful, as most worker threads will not handle the full contents of the stream.

Actually solving this shortcoming may come in future work, but for now we just warn about it in an @implNote