diff options
author | Paul Phillips <paulp@improving.org> | 2010-07-01 20:32:30 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2010-07-01 20:32:30 +0000 |
commit | deaf94e5f2bcbd719c1b80dfba2aaf16eaa9f75e (patch) | |
tree | d85b9d551f922ebb05bd2529be9f8606ce81b762 | |
parent | f0e000d7595faddecf4836b8a10452434829540f (diff) | |
download | scala-deaf94e5f2bcbd719c1b80dfba2aaf16eaa9f75e.tar.gz scala-deaf94e5f2bcbd719c1b80dfba2aaf16eaa9f75e.tar.bz2 scala-deaf94e5f2bcbd719c1b80dfba2aaf16eaa9f75e.zip |
Created mutable.SeqLike so as to mix in Cloneab...
Created mutable.SeqLike so as to mix in Cloneable like
mutable.{Set, Map} do. Closes #3590, review by odersky.
5 files changed, 33 insertions, 15 deletions
diff --git a/src/library/scala/collection/SetLike.scala b/src/library/scala/collection/SetLike.scala index 2e9a1ec2a2..fbbd77d8aa 100644 --- a/src/library/scala/collection/SetLike.scala +++ b/src/library/scala/collection/SetLike.scala @@ -11,7 +11,6 @@ package scala.collection import generic._ import mutable.{Builder, AddingBuilder} -import PartialFunction._ /** A template trait for sets. * diff --git a/src/library/scala/collection/mutable/BufferLike.scala b/src/library/scala/collection/mutable/BufferLike.scala index 80a8824a3b..dd4b5f303f 100644 --- a/src/library/scala/collection/mutable/BufferLike.scala +++ b/src/library/scala/collection/mutable/BufferLike.scala @@ -64,16 +64,13 @@ trait BufferLike[A, +This <: BufferLike[A, This] with Buffer[A]] with Shrinkable[A] with Scriptable[A] with Subtractable[A, This] - with Cloneable[This] with SeqLike[A, This] { self : This => // Note this does not extend Addable because `+` is being phased out of // all Seq-derived classes. - import scala.collection.{Iterable, Traversable} - - // Abstract methods from IndexedSeq: + // Abstract methods from Seq: def apply(n: Int): A def update(n: Int, newelem: A) @@ -99,7 +96,7 @@ trait BufferLike[A, +This <: BufferLike[A, This] with Buffer[A]] * @throws IndexOutofBoundsException if the index `n` is not in the valid range * `0 <= n <= length`. */ - def insertAll(n: Int, elems: Traversable[A]) + def insertAll(n: Int, elems: collection.Traversable[A]) /** Removes the element at a given index from this buffer. * diff --git a/src/library/scala/collection/mutable/PriorityQueue.scala b/src/library/scala/collection/mutable/PriorityQueue.scala index acdfc03597..b1ca5fde3c 100644 --- a/src/library/scala/collection/mutable/PriorityQueue.scala +++ b/src/library/scala/collection/mutable/PriorityQueue.scala @@ -37,7 +37,6 @@ class PriorityQueue[A](implicit ord: Ordering[A]) extends Seq[A] with SeqLike[A, PriorityQueue[A]] with Growable[A] - with Cloneable[PriorityQueue[A]] with Builder[A, PriorityQueue[A]] { import ord._ diff --git a/src/library/scala/collection/mutable/Seq.scala b/src/library/scala/collection/mutable/Seq.scala index eff387353e..c318dd34cf 100644 --- a/src/library/scala/collection/mutable/Seq.scala +++ b/src/library/scala/collection/mutable/Seq.scala @@ -29,14 +29,6 @@ trait Seq[A] extends Iterable[A] with GenericTraversableTemplate[A, Seq] with SeqLike[A, Seq[A]] { override def companion: GenericCompanion[Seq] = Seq - - /** Replaces element at given index with a new value. - * - * @param n the index of the element to replace. - * @param lem the new value. - * @throws IndexOutofBoundsException if the index is not valid. - */ - def update(idx: Int, elem: A) } /** $factoryInfo diff --git a/src/library/scala/collection/mutable/SeqLike.scala b/src/library/scala/collection/mutable/SeqLike.scala new file mode 100644 index 0000000000..e16aa37fe2 --- /dev/null +++ b/src/library/scala/collection/mutable/SeqLike.scala @@ -0,0 +1,31 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2010, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +package scala.collection +package mutable + +import generic._ + +/** A template trait for mutable sequences of type `mutable.Seq[A]`. + * @tparam A the type of the elements of the set + * @tparam This the type of the set itself. + * + */ +trait SeqLike[A, +This <: SeqLike[A, This] with Seq[A]] + extends scala.collection.SeqLike[A, This] + with Cloneable[This] { + self => + + /** Replaces element at given index with a new value. + * + * @param n the index of the element to replace. + * @param lem the new value. + * @throws IndexOutofBoundsException if the index is not valid. + */ + def update(idx: Int, elem: A) +} |