diff options
Diffstat (limited to 'src/library/scala/collection/immutable/Stream.scala')
-rw-r--r-- | src/library/scala/collection/immutable/Stream.scala | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/src/library/scala/collection/immutable/Stream.scala b/src/library/scala/collection/immutable/Stream.scala index 5989517532..d92b159f3b 100644 --- a/src/library/scala/collection/immutable/Stream.scala +++ b/src/library/scala/collection/immutable/Stream.scala @@ -11,7 +11,7 @@ package collection package immutable import generic._ -import mutable.{Builder, StringBuilder, LazyBuilder, ListBuffer} +import mutable.{Builder, StringBuilder, LazyBuilder} import scala.annotation.tailrec import Stream.cons import scala.language.implicitConversions @@ -176,9 +176,9 @@ import scala.language.implicitConversions * loop(1, 1) * } * }}} - * + * * Note that `mkString` forces evaluation of a `Stream`, but `addString` does - * not. In both cases, a `Stream` that is or ends in a cycle + * not. In both cases, a `Stream` that is or ends in a cycle * (e.g. `lazy val s: Stream[Int] = 0 #:: s`) will convert additional trips * through the cycle to `...`. Additionally, `addString` will display an * un-memoized tail as `?`. @@ -203,11 +203,9 @@ abstract class Stream[+A] extends AbstractSeq[A] with LinearSeq[A] with GenericTraversableTemplate[A, Stream] with LinearSeqOptimized[A, Stream[A]] - with Serializable { -self => - override def companion: GenericCompanion[Stream] = Stream + with Serializable { self => - import scala.collection.{Traversable, Iterable, Seq, IndexedSeq} + override def companion: GenericCompanion[Stream] = Stream /** Indicates whether or not the `Stream` is empty. * @@ -528,7 +526,7 @@ self => * unless the `f` throws an exception. */ @tailrec - override final def foreach[B](f: A => B) { + override final def foreach[U](f: A => U) { if (!this.isEmpty) { f(head) tail.foreach(f) @@ -1091,14 +1089,12 @@ object Stream extends SeqFactory[Stream] { /** Creates a new builder for a stream */ def newBuilder[A]: Builder[A, Stream[A]] = new StreamBuilder[A] - import scala.collection.{Iterable, Seq, IndexedSeq} - /** A builder for streams * @note This builder is lazy only in the sense that it does not go downs the spine * of traversables that are added as a whole. If more laziness can be achieved, * this builder should be bypassed. */ - class StreamBuilder[A] extends scala.collection.mutable.LazyBuilder[A, Stream[A]] { + class StreamBuilder[A] extends LazyBuilder[A, Stream[A]] { def result: Stream[A] = parts.toStream flatMap (_.toStream) } |