+str add zipWithIndex to FlowOps #21290

This commit is contained in:
Nafer Sanabria 2016-09-21 01:41:56 -05:00 committed by Johan Andrén
parent c1a840b2e9
commit 94d7237d17
11 changed files with 151 additions and 8 deletions

View file

@ -873,6 +873,21 @@ final class Source[+Out, +Mat](delegate: scaladsl.Source[Out, Mat]) extends Grap
matF: function.Function2[Mat, M, M2]): javadsl.Source[Out3, M2] =
new Source(delegate.zipWithMat[Out2, Out3, M, M2](that)(combinerToScala(combine))(combinerToScala(matF)))
/**
* Combine the elements of current [[Source]] into a stream of tuples consisting
* of all elements paired with their index. Indices start at 0.
*
* '''Emits when''' upstream emits an element and is paired with their index
*
* '''Backpressures when''' downstream backpressures
*
* '''Completes when''' upstream completes
*
* '''Cancels when''' downstream cancels
*/
def zipWithIndex: javadsl.Source[Pair[Out @uncheckedVariance, Long], Mat] =
new Source(delegate.zipWithIndex.map { case (elem, index) Pair(elem, index) })
/**
* Shortcut for running this `Source` with a foreach procedure. The given procedure is invoked
* for each received element.