Skip to content
This repository was archived by the owner on Dec 22, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions collections/src/main/scala/strawman/collection/View.scala
Original file line number Diff line number Diff line change
Expand Up @@ -308,11 +308,11 @@ trait IndexedView[+A] extends View[A] with ArrayLike[A] with SeqOps[A, View, Ind
override protected[this] def newSpecificBuilder(): Builder[A, IndexedView[A]] =
IndexedSeq.newBuilder[A]().mapResult(_.view)

def iterator(): Iterator[A] = new Iterator[A] {
def iterator(): Iterator[A] = new AbstractIterator[A] {
private var current = 0
def hasNext = current < self.length
def next(): A = {
val r = apply(current)
val r = self.apply(current)
current += 1
r
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,9 @@ sealed abstract class List[+A]
}
loop(null, null, this, this)
}

final override def toList: List[A] = this

}

@SerialVersionUID(6493291385232469459L) // value computed for strawman 0.6.0, scala 2.13.0-M2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package immutable
import strawman.collection.mutable.Builder

import scala.{Any, Boolean, `inline`, Int, None, NoSuchElementException, Nothing, Option, Some, Serializable, Unit}
import scala.Predef.<:<

/** Base type of immutable Maps */
trait Map[K, +V]
Expand Down Expand Up @@ -33,6 +34,9 @@ trait Map[K, +V]
* @return a wrapper of the map with a default value
*/
def withDefaultValue[V1 >: V](d: V1): Map[K, V1] = new Map.WithDefault[K, V1](this, x => d)

override final def toMap[K2, V2](implicit ev: (K, V) <:< (K2, V2)): Map[K2, V2] = this.asInstanceOf[Map[K2, V2]]

}

/** Base trait of immutable Maps implementations
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ object Seq extends SeqFactory.Delegate[Seq](List)
/** Base trait for immutable indexed sequences that have efficient `apply` and `length` */
trait IndexedSeq[+A] extends Seq[A]
with collection.IndexedSeq[A]
with IndexedSeqOps[A, IndexedSeq, IndexedSeq[A]]
with IndexedSeqOps[A, IndexedSeq, IndexedSeq[A]] {

final override def toIndexedSeq: IndexedSeq[A] = this

}

object IndexedSeq extends SeqFactory.Delegate[IndexedSeq](Vector)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ import strawman.collection.mutable.Builder
import scala.{Any, Boolean, Int, deprecatedName, `inline`, None, Option, Serializable, SerialVersionUID, Some, Unit}

/** Base trait for immutable set collections */
trait Set[A] extends Iterable[A] with collection.Set[A] with SetOps[A, Set, Set[A]]
trait Set[A] extends Iterable[A] with collection.Set[A] with SetOps[A, Set, Set[A]] {

override final def toSet[B >: A]: Set[B] = this.asInstanceOf[Set[B]]

}

/** Base trait for immutable set operations
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,8 @@ final class Vector[+A] private[immutable] (private[collection] val startIndex: I
s.cleanRightEdge(cutIndex - shift)
s
}

override def toVector: Vector[A] = this
}

class VectorIterator[+A](_startIndex: Int, endIndex: Int)
Expand Down