public final static < T > Stream < Vector < T > > grouped ( final Stream < T > stream , final int groupSize ) { return StreamSupport . stream ( new GroupingSpliterator <> ( stream . spliterator ( ) , ( ) -> Vector . empty ( ) , c -> Vector . fromIterable ( c ) , groupSize ) , stream . isParallel ( ) ) ; }
Group elements in a Stream by size