@@ -121,22 +121,27 @@ class Test {
121
121
122
122
Scala collections gain ` seqStream ` and ` parStream ` as extension methods that produce a Java 8 Stream
123
123
running sequentially or in parallel, respectively. These are automatically specialized to a primitive
124
- type if possible. For instance, ` List(1,2).seqStream ` produces an ` IntStream ` . Maps additionally have
124
+ type if possible, including automatically applied widening conversions. For instance, ` List(1,2).seqStream `
125
+ produces an ` IntStream ` , and so does ` List(1.toShort, 2.toShort).parStream ` . Maps additionally have
125
126
` seqKeyStream ` , ` seqValueStream ` , ` parKeyStream ` , and ` parValueStream ` methods.
126
127
127
128
Scala collections also gain ` accumulate ` and ` stepper ` methods that produce utility collections that
128
129
can be useful when working with Java 8 Streams. ` accumulate ` produces an ` Accumulator ` or its primitive
129
130
counterpart (` DoubleAccumulator ` , etc.), which is a low-level collection designed for efficient collection
130
131
and dispatching of results to and from Streams. Unlike most collections, it can contain more than
131
- ` Int.MaxValue ` elements. ` stepper ` produces a ` Stepper ` which is a fusion of ` Spliterator ` and ` Iterator ` .
132
- ` Stepper ` s underlie the Scala collections' instances of Java 8 Streams.
132
+ ` Int.MaxValue ` elements.
133
+
134
+ ` stepper ` produces a ` Stepper ` which is a fusion of ` Spliterator ` and ` Iterator ` . ` Stepper ` s underlie the Scala
135
+ collections' instances of Java 8 Streams. Steppers are intended as low-level building blocks for streams.
136
+ Usually you would not create them directly or call their methods but you can implement them alongside custom
137
+ collections to get better performance when streaming from these collections.
133
138
134
139
Java 8 Streams gain ` toScala[Coll] ` and ` accumulate ` methods, to make it easy to produce Scala collections
135
140
or Accumulators, respectively, from Java 8 Streams. For instance, ` myStream.to[Vector] ` will collect the
136
141
contents of a Stream into a ` scala.collection.immutable.Vector ` . Note that standard sequential builders
137
142
are used for collections, so this is best done to gather the results of an expensive computation.
138
143
139
- Finally, there is a Java class, ` ScalaStreamer ` , that has a series of ` from ` methods that can be used to
144
+ Finally, there is a Java class, ` ScalaStreamSupport ` , that has a series of ` stream ` methods that can be used to
140
145
obtain Java 8 Streams from Scala collections from within Java.
141
146
142
147
#### Performance Considerations
@@ -218,7 +223,7 @@ def mapToSortedString[A](xs: Vector[A], f: A => String, sep: String) =
218
223
#### Java Usage Example
219
224
220
225
To convert a Scala collection to a Java 8 Stream from within Java, it usually
221
- suffices to call ` ScalaStreaming.from (xs)` on your collection ` xs ` . If ` xs ` is
226
+ suffices to call ` ScalaStreamSupport.stream (xs)` on your collection ` xs ` . If ` xs ` is
222
227
a map, you may wish to get the keys or values alone by using ` fromKeys ` or
223
228
` fromValues ` . If the collection has an underlying representation that is not
224
229
efficiently parallelized (e.g. ` scala.collection.immutable.List ` ), then
@@ -237,14 +242,14 @@ Here is an example of conversion of a Scala collection within Java 8:
237
242
238
243
``` java
239
244
import scala.collection.mutable.ArrayBuffer ;
240
- import scala.compat.java8.ScalaStreaming ;
245
+ import scala.compat.java8.ScalaStreamSupport ;
241
246
242
247
public class StreamConvertersExample {
243
248
public int MakeAndUseArrayBuffer () {
244
249
ArrayBuffer<String > ab = new ArrayBuffer<String > ();
245
250
ab. $plus$eq(" salmon" );
246
251
ab. $plus$eq(" herring" );
247
- return ScalaStreaming . from (ab). mapToInt(x - > x. length()). sum(); // 6+7 = 13
252
+ return ScalaStreamSupport . stream (ab). mapToInt(x - > x. length()). sum(); // 6+7 = 13
248
253
}
249
254
}
250
255
```
0 commit comments