8072784: Better spliterator implementation for BitSet.stream()

Paul Sandoz paul.sandoz at oracle.com
Tue Nov 15 01:56:13 UTC 2016


Hi,

Please review this patch implementing a spliterator for BitSet:

  http://cr.openjdk.java.net/~psandoz/jdk9/JDK-8072784-bitset-stream-spliterator/webrev/

The spliterator is SIZED but not SUBSIZED, the bit set’s cardinality is used (same for the iterator) as the size of the root spliterator, and estimates from that are derived thereafter for splits. Splitting attempts to balance the small vs. large, dense vs. sparse cases.

Most of the complexity is dealing with the edge case of there being a bit set at Integer.MAX_VALUE.


Testing-wise i have leveraged the existing tests. It would be nice to consider placing the spliterator testing functionality into a separate library for reuse as SpliteratorTraversingAndSplittingTest is getting large. Likewise for more formally for streams, which is possible to reuse but a little clunky. I can log issues for those.

Paul.



More information about the core-libs-dev mailing list