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
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package strawman.collection.mutable

import scala.AnyRef

/** A trait for cloneable collections.
*
* @since 2.8
*
* @tparam A Type of the collection, covariant and with reference types as upperbound.
*/
trait Cloneable[+A <: AnyRef] extends scala.Cloneable {
override def clone(): A = super.clone().asInstanceOf[A]
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ import scala.{Boolean, None, Option, Some, Unit, `inline`, deprecated}
trait Map[K, V]
extends Iterable[(K, V)]
with collection.Map[K, V]
with MapOps[K, V, Map, Map[K, V]]
with Shrinkable[K] {
with MapOps[K, V, Map, Map[K, V]] {

/*
//TODO consider keeping `remove` because it returns the removed entry
Expand Down Expand Up @@ -53,10 +52,11 @@ trait Map[K, V]
trait MapOps[K, V, +CC[X, Y] <: MapOps[X, Y, CC, _], +C <: MapOps[K, V, CC, C]]
extends IterableOps[(K, V), Iterable, C]
with collection.MapOps[K, V, CC, C]
with Cloneable[C]
with Growable[(K, V)]
with Shrinkable[K] {

def iterableFactory = Iterable
def iterableFactory: IterableFactory[Iterable] = Iterable

/** Adds a new key/value pair to this map and optionally returns previously bound value.
* If the map already contains a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ object Seq extends SeqFactory.Delegate[Seq](ArrayBuffer)
*/
trait SeqOps[A, +CC[X] <: Seq[X], +C <: Seq[A]]
extends IterableOps[A, CC, C]
with collection.SeqOps[A, CC, C] {
with collection.SeqOps[A, CC, C]
with Cloneable[C] {

override def clone(): C = {
val b = newSpecificBuilder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ trait Set[A]
trait SetOps[A, +CC[X], +C <: SetOps[A, CC, C]]
extends IterableOps[A, CC, C]
with collection.SetOps[A, CC, C]
with Cloneable[C]
with Growable[A]
with Shrinkable[A] {

Expand Down