Skip to content
This repository has been archived by the owner on Dec 22, 2021. It is now read-only.

Commit

Permalink
Merge pull request #343 from julienrf/indexed-view
Browse files Browse the repository at this point in the history
Don’t force views elements prematurely.
  • Loading branch information
julienrf authored Jan 22, 2018
2 parents 73edfbb + 267a8a8 commit 5f39e81
Showing 1 changed file with 1 addition and 13 deletions.
14 changes: 1 addition & 13 deletions collections/src/main/scala/strawman/collection/View.scala
Original file line number Diff line number Diff line change
Expand Up @@ -313,19 +313,7 @@ trait ArrayLike[+A] extends Any { self =>
}

/** View defined in terms of indexing a range */
trait IndexedView[+A] extends View[A] with ArrayLike[A] with SeqOps[A, View, IndexedView[A]] { self =>

final override def toSeq: immutable.Seq[A] = to(immutable.IndexedSeq)

override protected[this] def fromSpecificIterable(it: Iterable[A]): IndexedView[A] =
it match {
case v: IndexedView[A] => v
case i: IndexedSeq[A] => i.view
case _ => it.to(IndexedSeq).view
}

override protected[this] def newSpecificBuilder(): Builder[A, IndexedView[A]] =
IndexedSeq.newBuilder[A]().mapResult(_.view)
trait IndexedView[+A] extends View[A] with ArrayLike[A] with SeqOps[A, View, View[A]] { self =>

def iterator(): Iterator[A] = new AbstractIterator[A] {
private var current = 0
Expand Down

0 comments on commit 5f39e81

Please sign in to comment.