@ SafeVarargs public static < T > Stream < T > interleave ( Function < T [ ] , Integer > selector , Stream < T > ... streams ) { Spliterator < T > [ ] spliterators = ( Spliterator < T > [ ] ) Stream . of ( streams ) . map ( BaseStream :: spliterator ) . toArray ( Spliterator [ ] :: new ) ; return StreamSupport . stream ( InterleavingSpliterator . interleaving ( spliterators , selector ) , false ) . onClose ( closerFor ( streams ) ) ; }
Construct a stream which interleaves the supplied streams picking items using the supplied selector function .