summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2009-05-14 11:02:47 +0000
committerMartin Odersky <odersky@gmail.com>2009-05-14 11:02:47 +0000
commitcafc8d6e57868b7353eb8846aba663cdf2db3335 (patch)
treed45918d91113355e1be0341ad45cff456764e723 /src
parentf665c2749c5d355820ae0f7097161ae7e0805b5e (diff)
downloadscala-cafc8d6e57868b7353eb8846aba663cdf2db3335.tar.gz
scala-cafc8d6e57868b7353eb8846aba663cdf2db3335.tar.bz2
scala-cafc8d6e57868b7353eb8846aba663cdf2db3335.zip
Removed plus/minus/fromOld
Diffstat (limited to 'src')
-rw-r--r--src/library/scala/collection/Iterable.scala8
-rw-r--r--src/library/scala/collection/Iterator.scala22
-rw-r--r--src/library/scala/collection/generic/Addable.scala43
-rw-r--r--src/library/scala/collection/generic/BufferTemplate.scala57
-rw-r--r--src/library/scala/collection/generic/Growable.scala6
-rw-r--r--src/library/scala/collection/generic/ImmutableMapTemplate.scala41
-rw-r--r--src/library/scala/collection/generic/MapTemplate.scala41
-rw-r--r--src/library/scala/collection/generic/MutableMapTemplate.scala44
-rwxr-xr-xsrc/library/scala/collection/generic/MutableMapTemplateBase.scala28
-rw-r--r--src/library/scala/collection/generic/MutableSetTemplate.scala49
-rw-r--r--src/library/scala/collection/generic/Shrinkable.scala2
-rw-r--r--src/library/scala/collection/generic/Subtractable.scala34
-rw-r--r--src/library/scala/collection/generic/TraversableTemplate.scala94
-rw-r--r--src/library/scala/collection/immutable/List.scala5
-rw-r--r--src/library/scala/collection/immutable/ListMap.scala2
-rw-r--r--src/library/scala/collection/immutable/SortedMap.scala40
-rw-r--r--src/library/scala/collection/immutable/Stream.scala2
-rw-r--r--src/library/scala/collection/mutable/LinkedHashSet.scala4
-rw-r--r--src/library/scala/collection/mutable/Queue.scala2
19 files changed, 140 insertions, 384 deletions
diff --git a/src/library/scala/collection/Iterable.scala b/src/library/scala/collection/Iterable.scala
index af52831428..1ec5dccd7c 100644
--- a/src/library/scala/collection/Iterable.scala
+++ b/src/library/scala/collection/Iterable.scala
@@ -54,14 +54,6 @@ object Iterable extends TraversableFactory[Iterable] {
implicit def builderFactory[A]: BuilderFactory[A, Iterable[A], Coll] = new VirtualBuilderFactory[A]
def newBuilder[A]: Builder[A, Iterable[A]] = immutable.Iterable.newBuilder[A]
- def fromOld[A](it: scala.Iterable[A]): Iterable[A] = new Iterable[A] {
- def elements: Iterator[A] = Iterator.fromOld(it.elements)
- }
-
- def toOld[A](it: Iterable[A]): scala.Iterable[A] = new scala.Iterable[A] {
- def elements: scala.Iterator[A] = Iterator.toOld(it.elements)
- }
-
/** The minimum element of a non-empty sequence of ordered elements
* @deprecated use seq.min instead
*/
diff --git a/src/library/scala/collection/Iterator.scala b/src/library/scala/collection/Iterator.scala
index 2e20595d76..a38cc6f360 100644
--- a/src/library/scala/collection/Iterator.scala
+++ b/src/library/scala/collection/Iterator.scala
@@ -23,16 +23,6 @@ import mutable.{Buffer, ArrayBuffer, ListBuffer}
*/
object Iterator {
- def fromOld[A](it: scala.Iterator[A]): Iterator[A] = new Iterator[A] {
- def hasNext: Boolean = it.hasNext
- def next: A = it.next
- }
-
- def toOld[A](it: Iterator[A]): scala.Iterator[A] = new scala.Iterator[A] {
- def hasNext: Boolean = it.hasNext
- def next: A = it.next
- }
-
val empty = new Iterator[Nothing] {
def hasNext: Boolean = false
def next(): Nothing = throw new NoSuchElementException("next on empty iterator")
@@ -53,15 +43,14 @@ object Iterator {
/** Creates an iterator with given elements
* @param elems The elements returned one-by-one from the iterator
*/
- def apply[A](elems: A*): Iterator[A] = Iterable.fromOld(elems).elements
+ def apply[A](elems: A*): Iterator[A] = elems.elements
/** Concatenates the given argument iterators into a single iterator.
*
* @param its the argument iterators that are to be concatenated
* @return the concatenation of all the argument iterators
*/
- @deprecated def concat[A](xss: Iterator[A]*): Iterator[A] =
- Iterable.fromOld(xss).elements.flatten
+ @deprecated def concat[A](xss: Iterator[A]*): Iterator[A] = xss.elements.flatten
/** An iterator that returns the results of some element computation a number of times.
* @param len The number of elements returned
@@ -178,7 +167,7 @@ object Iterator {
/** @deprecated use `xs.elements` instead
*/
- @deprecated def fromValues[a](xs: a*) = Iterable.fromOld(xs).elements
+ @deprecated def fromValues[a](xs: a*) = xs.elements
/**
* @param xs the array of elements
@@ -196,15 +185,14 @@ object Iterator {
* @deprecated use `xs.slice(start, start + length).elements` instead
*/
@deprecated def fromArray[a](xs: Array[a], start: Int, length: Int): Iterator[a] =
- Iterable.fromOld(xs.slice(start, start + length)).elements
+ xs.slice(start, start + length).elements
/**
* @param str the given string
* @return the iterator on <code>str</code>
* @deprecated replaced by <code>str.elements</code>
*/
- @deprecated def fromString(str: String): Iterator[Char] =
- Iterable.fromOld(str).elements
+ @deprecated def fromString(str: String): Iterator[Char] = str.elements
/**
* @param n the product arity
diff --git a/src/library/scala/collection/generic/Addable.scala b/src/library/scala/collection/generic/Addable.scala
index 56bfe4bd49..b6fcefb113 100644
--- a/src/library/scala/collection/generic/Addable.scala
+++ b/src/library/scala/collection/generic/Addable.scala
@@ -26,14 +26,6 @@ trait Addable[A, +This <: Addable[A, This]] { self =>
*/
def +(elem: A): This
- /** Creates a new collection with an additional element, unless the element is already present.
- * @param elem the element to be added
- * @return a fresh collection
- *
- * @note same as `+`
- */
- def plus (elem: A): This = this.+(elem)
-
/** Adds two or more elements to this collection and returns
* a new collection.
*
@@ -42,17 +34,7 @@ trait Addable[A, +This <: Addable[A, This]] { self =>
* @param elems the remaining elements to add.
*/
def + (elem1: A, elem2: A, elems: A*): This =
- this + elem1 + elem2 ++ Iterable.fromOld(elems)
-
- /** Adds two or more elements to this collection and returns
- * a new collection.
- *
- * @param elem1 the first element to add.
- * @param elem2 the second element to add.
- * @param elems the remaining elements to add.
- * @note same as `+`
- */
- def plus (elem1: A, elem2: A, elems: A*): This = this.+(elem1, elem2, elems: _*)
+ this + elem1 + elem2 ++ elems
/** Adds a number of elements provided by a traversable object
* and returns a new collection with the added elements.
@@ -61,35 +43,12 @@ trait Addable[A, +This <: Addable[A, This]] { self =>
*/
def ++(elems: Traversable[A]): This = (thisCollection /: elems) (_ + _)
- /** Adds a number of elements provided by a traversable object
- * and returns a new collection with the added elements.
- *
- * @param elems the traversable object.
- * @note This is a more efficient version of Traversiable.++ which avoids
- * copying of the collection's elements. However, it applies only if
- * the type of the added elements is a subtype of the element type of the
- * collection.
- */
- def plusAll (elems: Traversable[A]): This = this.++(elems)
-
/** Adds a number of elements provided by an iterator
* and returns a new collection with the added elements.
*
* @param iter the iterator
*/
def ++ (iter: Iterator[A]): This = (thisCollection /: iter) (_ + _)
-
- /** Adds a number of elements provided by an iterator
- * and returns a new collection with the added elements.
- *
- * @param iter the iterator
- * @note This is a more efficient version of Traversiable.++ which avoids
- * copying of the collection's elements. However, it applies only if
- * the type of the added elements is a subtype of the element type of the
- * collection.
- */
- def plusAll (iter: Iterator[A]): This = this.++(iter)
-
}
diff --git a/src/library/scala/collection/generic/BufferTemplate.scala b/src/library/scala/collection/generic/BufferTemplate.scala
index 981da34d02..7af9224297 100644
--- a/src/library/scala/collection/generic/BufferTemplate.scala
+++ b/src/library/scala/collection/generic/BufferTemplate.scala
@@ -114,29 +114,12 @@ trait BufferTemplate[A, +This <: BufferTemplate[A, This] with Buffer[A]]
this
}
- /** Perform a += on a clone of this collection */
- override def plus(elem: A): This = clone() += elem
- /** Perform a += on a clone of this collection */
- override def plus(elem1: A, elem2: A, elems: A*): This = clone() += (elem1, elem2, elems: _*)
- /** Perform a -= on a clone of this collection */
- override def minus(elem: A): This = clone() -= elem
- /** Perform a -= on a clone of this collection */
- override def minus(elem1: A, elem2: A, elems: A*): This = clone() -= (elem1, elem2, elems: _*)
- /** Perform a ++= on a clone of this collection */
- override def plusAll(elems: Traversable[A]): This = clone() ++= elems
- /** Perform a ++= on a clone of this collection */
- override def plusAll(elems: Iterator[A]): This = clone() ++= elems
- /** Perform a --= on a clone of this collection */
- override def minusAll(elems: Traversable[A]): This = clone() --= elems
- /** Perform a --= on a clone of this collection */
- override def minusAll(elems: Iterator[A]): This = clone() --= elems
-
/** Prepend two ore more elements to this buffer and return
* the identity of the buffer.
* @param elem the element to prepend.
*/
def +:(elem1: A, elem2: A, elems: A*): This =
- (elem1 +: elem2 +: Iterable.fromOld(elems) ++: thisCollection).asInstanceOf[This] // !!! does not work yet because conrete overrides abstract
+ (elem1 +: elem2 +: elems ++: thisCollection).asInstanceOf[This] // !!! does not work yet because conrete overrides abstract
/** Prepends a number of elements provided by an iterable object
* via its <code>elements</code> method. The identity of the
@@ -158,7 +141,7 @@ trait BufferTemplate[A, +This <: BufferTemplate[A, This] with Buffer[A]]
*
* @param elems the elements to append.
*/
- def append(elems: A*) { this ++= Iterable.fromOld(elems) }
+ def append(elems: A*) { this ++= elems }
/** Appends a number of elements provided by an iterable object
* via its <code>elements</code> method.
@@ -171,7 +154,7 @@ trait BufferTemplate[A, +This <: BufferTemplate[A, This] with Buffer[A]]
*
* @param elem the element to prepend.
*/
- def prepend(elems: A*) { Iterable.fromOld(elems) ++: this }
+ def prepend(elems: A*) { elems ++: this }
/** Prepends a number of elements provided by an iterable object
* via its <code>elements</code> method. The identity of the
@@ -196,7 +179,7 @@ trait BufferTemplate[A, +This <: BufferTemplate[A, This] with Buffer[A]]
* @param n the index where a new element will be inserted.
* @param elems the new elements to insert.
*/
- def insert(n: Int, elems: A*) { insertAll(n, Iterable.fromOld(elems)) }
+ def insert(n: Int, elems: A*) { insertAll(n, elems) }
/** Removes the first <code>n</code> elements.
*
@@ -267,8 +250,8 @@ trait BufferTemplate[A, +This <: BufferTemplate[A, This] with Buffer[A]]
* the collection itself.
*
* @param elem the element to add.
- * @deprecated use += instead if you inted to add by side effect to an existing collection.
- * Use `plus` if you intend to create a new collection.
+ * @deprecated use += instead if you intend to add by side effect to an existing collection.
+ * Use `clone() ++=` if you intend to create a new collection.
*/
@deprecated override def + (elem: A): This = { +=(elem); thisCollection }
@@ -278,8 +261,8 @@ trait BufferTemplate[A, +This <: BufferTemplate[A, This] with Buffer[A]]
* @param elem1 the first element to add.
* @param elem2 the second element to add.
* @param elems the remaining elements to add.
- * @deprecated use += instead if you inted to add by side effect to an existing collection.
- * Use `plus` if you intend to create a new collection.
+ * @deprecated use += instead if you intend to add by side effect to an existing collection.
+ * Use `clone() ++=` if you intend to create a new collection.
*/
@deprecated override def + (elem1: A, elem2: A, elems: A*): This = {
this += elem1 += elem2 ++= elems
@@ -290,8 +273,8 @@ trait BufferTemplate[A, +This <: BufferTemplate[A, This] with Buffer[A]]
* either the collection itself.
*
* @param iter the iterable object.
- * @deprecated use ++= instead if you inted to add by side effect to an existing collection.
- * Use `plusAll` if you intend to create a new collection.
+ * @deprecated use ++= instead if you intend to add by side effect to an existing collection.
+ * Use `clone() ++=` if you intend to create a new collection.
*/
@deprecated override def ++(iter: Traversable[A]): This = {
for (elem <- iter) +=(elem)
@@ -302,8 +285,8 @@ trait BufferTemplate[A, +This <: BufferTemplate[A, This] with Buffer[A]]
* the collection itself.
*
* @param iter the iterator
- * @deprecated use ++= instead if you inted to add by side effect to an existing collection.
- * Use `plusAll` if you intend to create a new collection.
+ * @deprecated use ++= instead if you intend to add by side effect to an existing collection.
+ * Use `clone() ++=` if you intend to create a new collection.
*/
@deprecated override def ++ (iter: Iterator[A]): This = {
for (elem <- iter) +=(elem)
@@ -314,8 +297,8 @@ trait BufferTemplate[A, +This <: BufferTemplate[A, This] with Buffer[A]]
* the collection itself.
*
* @param elem the element to remove.
- * @deprecated use -= instead if you inted to remove by side effect from an existing collection.
- * Use `minus` if you intend to create a new collection.
+ * @deprecated use -= instead if you intend to remove by side effect from an existing collection.
+ * Use `clone() -=` if you intend to create a new collection.
*/
@deprecated override def -(elem: A): This = { -=(elem); thisCollection }
@@ -325,8 +308,8 @@ trait BufferTemplate[A, +This <: BufferTemplate[A, This] with Buffer[A]]
* @param elem1 the first element to remove.
* @param elem2 the second element to remove.
* @param elems the remaining elements to remove.
- * @deprecated use -= instead if you inted to remove by side effect from an existing collection.
- * Use `minus` if you intend to create a new collection.
+ * @deprecated use -= instead if you intend to remove by side effect from an existing collection.
+ * Use `clone() -=` if you intend to create a new collection.
*/
@deprecated override def -(elem1: A, elem2: A, elems: A*): This = {
this -= elem1 -= elem2 --= elems
@@ -335,8 +318,8 @@ trait BufferTemplate[A, +This <: BufferTemplate[A, This] with Buffer[A]]
/** Removes a number of elements provided by a traversible object and returns
* the collection itself.
- * @deprecated use --= instead if you inted to remove by side effect from an existing collection.
- * Use `minusAll` if you intend to create a new collection.
+ * @deprecated use --= instead if you intend to remove by side effect from an existing collection.
+ * Use `clone() --=` if you intend to create a new collection.
*
* @param iter the iterable object.
*/
@@ -349,8 +332,8 @@ trait BufferTemplate[A, +This <: BufferTemplate[A, This] with Buffer[A]]
* the collection itself.
*
* @param iter the iterator
- * @deprecated use --= instead if you inted to remove by side effect from an existing collection.
- * Use `minusAll` if you intend to create a new collection.
+ * @deprecated use --= instead if you intend to remove by side effect from an existing collection.
+ * Use `clone() --=` if you intend to create a new collection.
*/
@deprecated override def --(iter: Iterator[A]): This = {
for (elem <- iter) -=(elem)
diff --git a/src/library/scala/collection/generic/Growable.scala b/src/library/scala/collection/generic/Growable.scala
index 804f824422..a085c9f9fd 100644
--- a/src/library/scala/collection/generic/Growable.scala
+++ b/src/library/scala/collection/generic/Growable.scala
@@ -31,11 +31,7 @@ trait Growable[-A] {
* @param elem2 the second element to add.
* @param elems the remaining elements to add.
*/
- def +=(elem1: A, elem2: A, elems: A*): this.type = {
- this += elem1
- this += elem2
- this ++= Iterable.fromOld(elems)
- }
+ def +=(elem1: A, elem2: A, elems: A*): this.type = this += elem1 += elem2 ++= elems
/** Adds a number of elements provided by an iterator to this collection.
*
diff --git a/src/library/scala/collection/generic/ImmutableMapTemplate.scala b/src/library/scala/collection/generic/ImmutableMapTemplate.scala
index db1b232d1b..005d561ff0 100644
--- a/src/library/scala/collection/generic/ImmutableMapTemplate.scala
+++ b/src/library/scala/collection/generic/ImmutableMapTemplate.scala
@@ -44,13 +44,6 @@ self =>
* @param kv the key/value pair
* @return A new map with the new binding added to this map
*/
- override def plus [B1 >: B] (kv: (A, B1)): immutable.Map[A, B1] = this + kv
-
- /** Add a key/value pair to this map, returning a new map.
- * @param kv the key/value pair
- * @return A new map with the new binding added to this map
- * @note same as `plus`
- */
def + [B1 >: B] (kv: (A, B1)): immutable.Map[A, B1]
/** Adds two or more elements to this collection and returns
@@ -63,16 +56,6 @@ self =>
override def + [B1 >: B] (elem1: (A, B1), elem2: (A, B1), elems: (A, B1) *): immutable.Map[A, B1] =
this + elem1 + elem2 ++ elems
- /** Adds two or more elements to this collection and returns
- * a new collection.
- *
- * @param elem1 the first element to add.
- * @param elem2 the second element to add.
- * @param elems the remaining elements to add.
- */
- override def plus [B1 >: B] (elem1: (A, B1), elem2: (A, B1), elems: (A, B1) *): immutable.Map[A, B1] =
- this.+(elem1, elem2, elems: _*)
-
/** Adds a number of elements provided by a traversable object
* and returns a new collection with the added elements.
*
@@ -81,18 +64,6 @@ self =>
override def ++[B1 >: B](elems: Traversable[(A, B1)]): immutable.Map[A, B1] =
((thisCollection: immutable.Map[A, B1]) /: elems) (_ + _)
- /** Adds a number of elements provided by a traversable object
- * and returns a new collection with the added elements.
- *
- * @param elems the traversable object.
- * @note same as `++`
- * @note This is a more efficient version of Traversable.++ which avoids
- * copying of the collection's elements. However, it applies only if
- * the type of the added elements is a subtype of the element type of the
- * collection.
- */
- override def plusAll [B1 >: B](elems: Traversable[(A, B1)]): immutable.Map[A, B1] = this.++(elems)
-
/** Adds a number of elements provided by an iterator
* and returns a new collection with the added elements.
*
@@ -101,18 +72,6 @@ self =>
override def ++[B1 >: B] (iter: Iterator[(A, B1)]): immutable.Map[A, B1] =
((thisCollection: immutable.Map[A, B1]) /: iter) (_ + _)
- /** Adds a number of elements provided by an iterator
- * and returns a new collection with the added elements.
- *
- * @param iter the iterator
- * @note same as `++`
- * @note This is a more efficient version of Traversable.++ which avoids
- * copying of the collection's elements. However, it applies only if
- * the type of the added elements is a subtype of the element type of the
- * collection.
- */
- override def plusAll [B1 >: B](iter: Iterator[(A, B1)]): immutable.Map[A, B1] = this.++(iter)
-
/** This function transforms all the values of mappings contained
* in this map with function <code>f</code>.
*
diff --git a/src/library/scala/collection/generic/MapTemplate.scala b/src/library/scala/collection/generic/MapTemplate.scala
index 1076347977..5333120df9 100644
--- a/src/library/scala/collection/generic/MapTemplate.scala
+++ b/src/library/scala/collection/generic/MapTemplate.scala
@@ -170,13 +170,6 @@ self =>
*/
def + [B1 >: B] (kv: (A, B1)): Map[A, B1]
- /** Add a key/value pair to this map, returning a new map.
- * @param kv the key/value pair
- * @return A new map with the new binding added to this map
- * @note same as `+`
- */
- def plus [B1 >: B] (kv: (A, B1)): Map[A, B1] = this + kv
-
/** Adds two or more elements to this collection and returns
* a new collection.
*
@@ -187,16 +180,6 @@ self =>
def + [B1 >: B] (elem1: (A, B1), elem2: (A, B1), elems: (A, B1) *): Map[A, B1] =
this + elem1 + elem2 ++ elems
- /** Adds two or more elements to this collection and returns
- * a new collection.
- *
- * @param elem1 the first element to add.
- * @param elem2 the second element to add.
- * @param elems the remaining elements to add.
- */
- def plus [B1 >: B] (elem1: (A, B1), elem2: (A, B1), elems: (A, B1) *): Map[A, B1] =
- this.+(elem1, elem2, elems: _*)
-
/** Adds a number of elements provided by a traversable object
* and returns a new collection with the added elements.
*
@@ -205,18 +188,6 @@ self =>
def ++[B1 >: B](elems: Traversable[(A, B1)]): Map[A, B1] =
((thisCollection: Map[A, B1]) /: elems) (_ + _)
- /** Adds a number of elements provided by a traversable object
- * and returns a new collection with the added elements.
- *
- * @param elems the traversable object.
- * @note same as `++`
- * @note This is a more efficient version of Traversable.++ which avoids
- * copying of the collection's elements. However, it applies only if
- * the type of the added elements is a subtype of the element type of the
- * collection.
- */
- def plusAll [B1 >: B](elems: Traversable[(A, B1)]): Map[A, B1] = this.++(elems)
-
/** Adds a number of elements provided by an iterator
* and returns a new collection with the added elements.
*
@@ -225,18 +196,6 @@ self =>
def ++[B1 >: B] (iter: Iterator[(A, B1)]): Map[A, B1] =
((thisCollection: Map[A, B1]) /: iter) (_ + _)
- /** Adds a number of elements provided by an iterator
- * and returns a new collection with the added elements.
- *
- * @param iter the iterator
- * @note same as `++`
- * @note This is a more efficient version of Traversable.++ which avoids
- * copying of the collection's elements. However, it applies only if
- * the type of the added elements is a subtype of the element type of the
- * collection.
- */
- def plusAll [B1 >: B](iter: Iterator[(A, B1)]): Map[A, B1] = this.++(iter)
-
/** Removes a key from this map, returning a new map
* @param key the key to be removed
* @return A new map without a binding for <code>key</code>
diff --git a/src/library/scala/collection/generic/MutableMapTemplate.scala b/src/library/scala/collection/generic/MutableMapTemplate.scala
index 72c4f9ceda..d7efc0bd0a 100644
--- a/src/library/scala/collection/generic/MutableMapTemplate.scala
+++ b/src/library/scala/collection/generic/MutableMapTemplate.scala
@@ -70,29 +70,11 @@ trait MutableMapTemplate[A, B, +This <: MutableMapTemplate[A, B, This] with muta
/** Create a new map consisting of all elements of the current map
* plus the given mapping from `key` to `value`.
- * @param key The key to add
+ * @param key The key to ad
* @param value The new value
* @return A fresh immutable map
*/
- override def updated[B1 >: B](key: A, value: B1): collection.Map[A, B1] =
- plus((key, value))
-
- /** Perform a += on a clone of this collection */
- override def plus[B1 >: B](kv: (A, B1)): mutable.Map[A, B1] = clone().asInstanceOf[mutable.Map[A, B1]] += kv
- /** Perform a += on a clone of this collection */
- override def plus[B1 >: B](kv1: (A, B1), kv2: (A, B1), kvs: (A, B1)*): mutable.Map[A, B1] = clone().asInstanceOf[mutable.Map[A, B1]] += (kv1, kv2, kvs: _*)
- /** Perform a -= on a clone of this collection */
- override def minus(key: A): This = clone() -= key
- /** Perform a -= on a clone of this collection */
- override def minus(key1: A, key2: A, keys: A*): This = clone() -= (key1, key2, keys: _*)
- /** Perform a ++= on a clone of this collection */
- override def plusAll[B1 >: B](kvs: Traversable[(A, B1)]): mutable.Map[A, B1] = clone().asInstanceOf[mutable.Map[A, B1]] ++= kvs
- /** Perform a ++= on a clone of this collection */
- override def plusAll[B1 >: B](kvs: Iterator[(A, B1)]): mutable.Map[A, B1] = clone().asInstanceOf[mutable.Map[A, B1]] ++= kvs
- /** Perform a --= on a clone of this collection */
- override def minusAll(keys: Traversable[A]): This = clone() --= keys
- /** Perform a --= on a clone of this collection */
- override def minusAll(keys: Iterator[A]): This = clone() --= keys
+ override def updated[B1 >: B](key: A, value: B1): mutable.Map[A, B1] = this + ((key, value))
/** Add a new key/value mapping and return the map itself.
*
@@ -100,7 +82,7 @@ trait MutableMapTemplate[A, B, +This <: MutableMapTemplate[A, B, This] with muta
* @deprecated This operation will create a new map in the future. To add
* an element as a side effect to an existing map and return
* that map itself, use +=. If you do want to create a fresh map,
- * you can use `plus` to avoid a @deprecated warning.
+ * you can use `clone() +=` to avoid a @deprecated warning.
*/
@deprecated def + (kv: (A, B)): this.type = { update(kv._1, kv._2); this }
@@ -113,7 +95,7 @@ trait MutableMapTemplate[A, B, +This <: MutableMapTemplate[A, B, This] with muta
* @deprecated This operation will create a new map in the future. To add
* an element as a side effect to an existing map and return
* that map itself, use +=. If you do want to create a fresh map,
- * you can use `plus` to avoid a @deprecated warning.
+ * you can use `clone() +=` to avoid a @deprecated warning.
*/
@deprecated def +(elem1: (A, B), elem2: (A, B), elems: (A, B)*): this.type =
this += elem1 += elem2 ++= elems
@@ -125,7 +107,7 @@ trait MutableMapTemplate[A, B, +This <: MutableMapTemplate[A, B, This] with muta
* @deprecated This operation will create a new map in the future. To add
* elements as a side effect to an existing map and return
* that map itself, use ++=. If you do want to create a fresh map,
- * you can use `plusAll` to avoid a @deprecated warning.
+ * you can use `clone() ++=` to avoid a @deprecated warning.
* @param iter the traversable object.
*/
@deprecated def ++(iter: Traversable[(A, B)]): this.type = { for (elem <- iter) +=(elem); this }
@@ -136,7 +118,7 @@ trait MutableMapTemplate[A, B, +This <: MutableMapTemplate[A, B, This] with muta
* @deprecated This operation will create a new map in the future. To add
* elements as a side effect to an existing map and return
* that map itself, use ++=. If you do want to create a fresh map,
- * you can use `plus` to avoid a @deprecated warning.
+ * you can use `clone() +=` to avoid a @deprecated warning.
*
* @param iter the iterator
*/
@@ -163,7 +145,7 @@ trait MutableMapTemplate[A, B, +This <: MutableMapTemplate[A, B, This] with muta
* @deprecated This operation will create a new map in the future. To add
* elements as a side effect to an existing map and return
* that map itself, use -=. If you do want to create a fresh map,
- * you can use `minus` to avoid a @deprecated warning.
+ * you can use `clone() -=` to avoid a @deprecated warning.
*/
@deprecated override def -(key: A): This = { -=(key); thisCollection }
@@ -225,8 +207,8 @@ trait MutableMapTemplate[A, B, +This <: MutableMapTemplate[A, B, This] with muta
* @param elem1 the first element to remove.
* @param elem2 the second element to remove.
* @param elems the remaining elements to remove.
- * @deprecated use -= instead if you inted to remove by side effect from an existing collection.
- * Use `minus` if you intend to create a new collection.
+ * @deprecated use -= instead if you intend to remove by side effect from an existing collection.
+ * Use `clone() -=` if you intend to create a new collection.
*/
@deprecated override def -(elem1: A, elem2: A, elems: A*): This = {
this -= elem1 -= elem2 --= elems
@@ -235,8 +217,8 @@ trait MutableMapTemplate[A, B, +This <: MutableMapTemplate[A, B, This] with muta
/** Removes a number of elements provided by a traversible object and returns
* the collection itself.
- * @deprecated use --= instead if you inted to remove by side effect from an existing collection.
- * Use `minusAll` if you intend to create a new collection.
+ * @deprecated use --= instead if you intend to remove by side effect from an existing collection.
+ * Use `clone() --=` if you intend to create a new collection.
*
* @param iter the iterable object.
*/
@@ -250,8 +232,8 @@ trait MutableMapTemplate[A, B, +This <: MutableMapTemplate[A, B, This] with muta
* the collection itself.
*
* @param iter the iterator
- * @deprecated use --= instead if you inted to remove by side effect from an existing collection.
- * Use `minusAll` if you intend to create a new collection.
+ * @deprecated use --= instead if you intend to remove by side effect from an existing collection.
+ * Use `clone() --=` if you intend to create a new collection.
*/
@deprecated override def --(iter: Iterator[A]): This = {
for (elem <- iter) -=(elem)
diff --git a/src/library/scala/collection/generic/MutableMapTemplateBase.scala b/src/library/scala/collection/generic/MutableMapTemplateBase.scala
index 8a0809792b..2c5f39f76c 100755
--- a/src/library/scala/collection/generic/MutableMapTemplateBase.scala
+++ b/src/library/scala/collection/generic/MutableMapTemplateBase.scala
@@ -11,25 +11,25 @@
package scala.collection.generic
-/** A generic template for mutable maps from keys of type A to values of type B.
- * To implement a concrete mutable map, you need to provide implementations of the following methods:
+/** The reason for this class is so that we can
+ * have both a generic immutable `+` with signature
*
- * def get(key: A): Option[B]
- * def elements: Iterator[(A, B)]
- * def += (kv: (A, B)): this.type
- * def -= (key: A): this.type
+ * def + [B1 >: B](kv: (A, B1)): Map[A, B1]
*
- * If you wish that methods like, take, drop, filter return the same kind of map, you should also
- * override:
+ * and a (deprecated) mutable `+` of signature
*
- * def empty: This
+ * def + (kv: (A, B)): this.type = this += kv
*
- * If you to avoid the unncessary construction of an Option object,
- * you could also override apply, update, and delete.
- * It is also good idea to override methods `foreach` and `size` for efficiency.
+ * The former is required to fulfill the Map contract.
+ * The latter is required for backwards compatibility.
+ * We can't have both methods in the same class, as that would give a double definition.
+ * They are OK in different classes though, and narrowly escape a `same erasure' problem.
+ * Once the deprecated + goes away we can do without class MutableMapTemplateBase.
*
+ * @author Martin Odersky
+ * @version 2.8
*/
trait MutableMapTemplateBase[A, B, +This <: MutableMapTemplateBase[A, B, This] with mutable.Map[A, B]]
- extends MapTemplate[A, B, This] {
- def + [B1 >: B] (kv: (A, B1)): Map[A, B1] = plus(kv)
+ extends MapTemplate[A, B, This] with Cloneable[This] {
+ def + [B1 >: B] (kv: (A, B1)): mutable.Map[A, B1] = clone().asInstanceOf[mutable.Map[A, B1]] += kv
}
diff --git a/src/library/scala/collection/generic/MutableSetTemplate.scala b/src/library/scala/collection/generic/MutableSetTemplate.scala
index 8c5ee54c25..c0780ad66e 100644
--- a/src/library/scala/collection/generic/MutableSetTemplate.scala
+++ b/src/library/scala/collection/generic/MutableSetTemplate.scala
@@ -93,31 +93,14 @@ trait MutableSetTemplate[A, +This <: MutableSetTemplate[A, This] with mutable.Se
override def clone(): This = empty ++= thisCollection
- /** Perform a += on a clone of this collection */
- override def plus(elem: A): This = clone() += elem
- /** Perform a += on a clone of this collection */
- override def plus(elem1: A, elem2: A, elems: A*): This = clone() += (elem1, elem2, elems: _*)
- /** Perform a -= on a clone of this collection */
- override def minus(elem: A): This = clone() -= elem
- /** Perform a -= on a clone of this collection */
- override def minus(elem1: A, elem2: A, elems: A*): This = clone() -= (elem1, elem2, elems: _*)
- /** Perform a ++= on a clone of this collection */
- override def plusAll(elems: Traversable[A]): This = clone() ++= elems
- /** Perform a ++= on a clone of this collection */
- override def plusAll(elems: Iterator[A]): This = clone() ++= elems
- /** Perform a --= on a clone of this collection */
- override def minusAll(elems: Traversable[A]): This = clone() --= elems
- /** Perform a --= on a clone of this collection */
- override def minusAll(elems: Iterator[A]): This = clone() --= elems
-
def result: This = thisCollection
/** Adds a single element to this collection and returns
* the collection itself.
*
* @param elem the element to add.
- * @deprecated use += instead if you inted to add by side effect to an existing collection.
- * Use `plus` if you intend to create a new collection.
+ * @deprecated use += instead if you intend to add by side effect to an existing collection.
+ * Use `clone() +=` if you intend to create a new collection.
*/
@deprecated override def + (elem: A): This = { +=(elem); thisCollection }
@@ -127,8 +110,8 @@ trait MutableSetTemplate[A, +This <: MutableSetTemplate[A, This] with mutable.Se
* @param elem1 the first element to add.
* @param elem2 the second element to add.
* @param elems the remaining elements to add.
- * @deprecated use += instead if you inted to add by side effect to an existing collection.
- * Use `plus` if you intend to create a new collection.
+ * @deprecated use += instead if you intend to add by side effect to an existing collection.
+ * Use `clone() +=` if you intend to create a new collection.
*/
@deprecated override def + (elem1: A, elem2: A, elems: A*): This = {
this += elem1 += elem2 ++= elems
@@ -139,8 +122,8 @@ trait MutableSetTemplate[A, +This <: MutableSetTemplate[A, This] with mutable.Se
* either the collection itself.
*
* @param iter the iterable object.
- * @deprecated use ++= instead if you inted to add by side effect to an existing collection.
- * Use `plusAll` if you intend to create a new collection.
+ * @deprecated use ++= instead if you intend to add by side effect to an existing collection.
+ * Use `clone() ++=` if you intend to create a new collection.
*/
@deprecated override def ++(iter: Traversable[A]): This = {
for (elem <- iter) +=(elem)
@@ -152,8 +135,8 @@ trait MutableSetTemplate[A, +This <: MutableSetTemplate[A, This] with mutable.Se
* the collection itself.
*
* @param iter the iterator
- * @deprecated use ++= instead if you inted to add by side effect to an existing collection.
- * Use `plusAll` if you intend to create a new collection.
+ * @deprecated use ++= instead if you intend to add by side effect to an existing collection.
+ * Use `clone() ++=` if you intend to create a new collection.
*/
@deprecated override def ++ (iter: Iterator[A]): This = {
for (elem <- iter) +=(elem)
@@ -164,8 +147,8 @@ trait MutableSetTemplate[A, +This <: MutableSetTemplate[A, This] with mutable.Se
* the collection itself.
*
* @param elem the element to remove.
- * @deprecated use -= instead if you inted to remove by side effect from an existing collection.
- * Use `minus` if you intend to create a new collection.
+ * @deprecated use -= instead if you intend to remove by side effect from an existing collection.
+ * Use `clone() -=` if you intend to create a new collection.
*/
@deprecated override def -(elem: A): This = { -=(elem); thisCollection }
@@ -175,8 +158,8 @@ trait MutableSetTemplate[A, +This <: MutableSetTemplate[A, This] with mutable.Se
* @param elem1 the first element to remove.
* @param elem2 the second element to remove.
* @param elems the remaining elements to remove.
- * @deprecated use -= instead if you inted to remove by side effect from an existing collection.
- * Use `minus` if you intend to create a new collection.
+ * @deprecated use -= instead if you intend to remove by side effect from an existing collection.
+ * Use `clone() -=` if you intend to create a new collection.
*/
@deprecated override def -(elem1: A, elem2: A, elems: A*): This = {
this -= elem1 -= elem2 --= elems
@@ -185,8 +168,8 @@ trait MutableSetTemplate[A, +This <: MutableSetTemplate[A, This] with mutable.Se
/** Removes a number of elements provided by a traversible object and returns
* the collection itself.
- * @deprecated use --= instead if you inted to remove by side effect from an existing collection.
- * Use `minusAll` if you intend to create a new collection.
+ * @deprecated use --= instead if you intend to remove by side effect from an existing collection.
+ * Use `clone() --=` if you intend to create a new collection.
*
* @param iter the iterable object.
*/
@@ -199,8 +182,8 @@ trait MutableSetTemplate[A, +This <: MutableSetTemplate[A, This] with mutable.Se
* the collection itself.
*
* @param iter the iterator
- * @deprecated use --= instead if you inted to remove by side effect from an existing collection.
- * Use `minusAll` if you intend to create a new collection.
+ * @deprecated use --= instead if you intend to remove by side effect from an existing collection.
+ * Use `clone() --=` if you intend to create a new collection.
*/
@deprecated override def --(iter: Iterator[A]): This = {
for (elem <- iter) -=(elem)
diff --git a/src/library/scala/collection/generic/Shrinkable.scala b/src/library/scala/collection/generic/Shrinkable.scala
index 6eecbaac3b..227b47af44 100644
--- a/src/library/scala/collection/generic/Shrinkable.scala
+++ b/src/library/scala/collection/generic/Shrinkable.scala
@@ -33,7 +33,7 @@ trait Shrinkable[-A] {
def -=(elem1: A, elem2: A, elems: A*): this.type = {
this -= elem1
this -= elem2
- this --= Iterable.fromOld(elems)
+ this --= elems
}
/** Removes a number of elements provided by an iterator from this collection.
diff --git a/src/library/scala/collection/generic/Subtractable.scala b/src/library/scala/collection/generic/Subtractable.scala
index 5d264759ee..4847dedbff 100644
--- a/src/library/scala/collection/generic/Subtractable.scala
+++ b/src/library/scala/collection/generic/Subtractable.scala
@@ -28,14 +28,6 @@ trait Subtractable[A, +This <: Subtractable[A, This]] { self =>
def -(elem: A): This
/** Returns a new collection that contains all elements of the current collection
- * except a given element.
- *
- * @param elem the element to remove.
- * @note same as `-`
- */
- def minus(elem: A): This = this - elem
-
- /** Returns a new collection that contains all elements of the current collection
* except a two or more given elements.
*
* @param elem1 the first element to remove.
@@ -46,16 +38,6 @@ trait Subtractable[A, +This <: Subtractable[A, This]] { self =>
this - elem1 - elem2 -- elems
/** Returns a new collection that contains all elements of the current collection
- * except two or more given elements.
- *
- * @param elem1 the first element to remove.
- * @param elem2 the second element to remove.
- * @param elems the remaining elements to remove.
- * @note same as -
- */
- def minus (elem1: A, elem2: A, elems: A*): This = this - (elem1, elem2, elems: _*)
-
- /** Returns a new collection that contains all elements of the current collection
* except the elements provided by a traversable object
*
* @param elems the traversable object containing the elements that do not form part of the new collection.
@@ -63,26 +45,10 @@ trait Subtractable[A, +This <: Subtractable[A, This]] { self =>
def --(elems: Traversable[A]): This = (thisCollection /: elems) (_ - _)
/** Returns a new collection that contains all elements of the current collection
- * except the elements provided by a traversable object
- *
- * @param elems the traversable object containing the elements that do not form part of the new collection.
- * @note same as --
- */
- def minusAll(elems: Traversable[A]): This = this -- elems
-
- /** Returns a new collection that contains all elements of the current collection
* except the elements provided by an iterator
*
* @param elems the iterator containing the elements that do not form part of the new collection
* @note same as --
*/
def --(iter: Iterator[A]): This = (thisCollection /: iter) (_ - _)
-
- /** Returns a new collection that contains all elements of the current collection
- * except the elements provided by an iterator
- *
- * @param elems the iterator containing the elements that do not form part of the new collection
- * @note same as --
- */
- def minusAll(iter: Iterator[A]): This = this -- iter
}
diff --git a/src/library/scala/collection/generic/TraversableTemplate.scala b/src/library/scala/collection/generic/TraversableTemplate.scala
index aa651de27b..9992df1a95 100644
--- a/src/library/scala/collection/generic/TraversableTemplate.scala
+++ b/src/library/scala/collection/generic/TraversableTemplate.scala
@@ -14,26 +14,66 @@ import mutable.{Buffer, ArrayBuffer, ListBuffer}
import util.control.Breaks._
/** A template trait for traversable collections.
+ * This is a base trait of all kinds of Scala collections. It implements the
+ * behavior common to all collections, in terms of a method `foreach` with signature:
*
- * Collection classes mixing in this trait provide a method
- * <code>foreach</code> which traverses all the
- * elements contained in the collection, applying a given procedure to each.
- * They also provide a method `newBuilder`
+ * def foreach[U](f: Elem => U): Unit
+ *
+ * Collection classes mixing in this trait provide a concrete
+ * <code>foreach</code> method which traverses all the
+ * elements contained in the collection, applying a given function to each.
+ * They also need to provide a method `newBuilder`
* which creates a builder for collections of the same kind.
*
+ * A traversable class might or might not have two properties: strictness and orderedness.
+ * Neither is represented as a type.
+ *
+ * The instances of a strict collection class have all their elements computed before
+ * they can be used as values. By contrast, instances of a non-strict collection class
+ * may defer computation of some of their elements until after the instance is available as a value.
+ * A typical example of a non-strict collection class is a scala.immutable.Stream.
+ * A more general class of examples are TraversableViews.
+ *
+ * If a collection is an instance of an ordered collection class, traversing its elements
+ * with `foreach` will always visit elements in the same order, even for different
+ * runs of the program. If the class is not ordered, `foreach` can visit elements
+ * in different orders for different runs (but it will keep the same order in the same run).
+ * A typical example of a collection class which is not ordered is a `HashMap` of objects.
+ * The traversal order for hash maps will depend on the hash codes of its elements, and
+ * these hash codes might differ from one run to the next. By contrast, a `LinkedHashMap`
+ * is odered because it's `foreach` method visits elements in the order they were inserted
+ * into the `HashMap`.
+ *
* @author Martin Odersky
* @version 2.8
*/
trait TraversableTemplate[+A, +This <: TraversableTemplate[A, This] with Traversable[A]] {
self =>
+ /** The proper way to do this would be to make `self` of type `This`. But unfortunately this
+ * makes `this` to be of type `Traversable[A]`. Since `Traversable` is a subtype of
+ * `TraversableTemplate` this means that all methods of `this` are taken from `Traversable`.
+ */
protected def thisCollection: This = this.asInstanceOf[This]
- /** Create a new builder for this traversable type.
+ protected def thisTemplate: TraversableTemplate[A, This] = this
+
+ /** Create a new builder for this collection type.
*/
protected[this] def newBuilder: Builder[A, This]
- /** Is this collection empty?
+ /** Apply a function <code>f</code> to all elements of this
+ * traversable object.
+ *
+ * @param f A function that is applied for its side-effect to every element.
+ * The result (of arbitrary type U) of function `f` is discarded.
+ *
+ * @note This method underlies the implementation of most other bulk operations.
+ * It's important to implement this method in an efficient way.
+ */
+ def foreach[U](f: A => U): Unit
+
+ /** Does this collection contain no elements?
*/
def isEmpty: Boolean = {
var result = true
@@ -46,7 +86,12 @@ self =>
result
}
- /** The number of elements in this collection */
+ /** Does this collection contain some elements?
+ */
+ def nonEmpty: Boolean = !isEmpty
+
+ /** The number of elements in this collection
+ */
def size: Int = {
var result = 0
breakable {
@@ -55,14 +100,17 @@ self =>
result
}
- /** returns true iff this collection has a finite size.
+ /** Returns true if this collection is known to have finite size.
+ * This is the case if the collection type is strict, or if the
+ * collection type is non-strict (e.g. it's a Stream), but all
+ * collection elements have been computed.
* Many methods in this trait will not work on collections of
* infinite sizes.
*/
def hasDefiniteSize = true
/** Creates a new traversable of type `That` which contains all elements of this traversable
- * followed by all elements of another traversable
+ * followed by all elements of another traversable.
*
* @param that The traversable to append
*/
@@ -73,8 +121,8 @@ self =>
b.result
}
- /** Create a new traversable of type `That` which contains all elements of this traversable
- * followed by all elements of an iterator
+ /** Creates a new traversable of type `That` which contains all elements of this traversable
+ * followed by all elements of an iterator.
*
* @param that The iterator to append
*/
@@ -85,18 +133,11 @@ self =>
b.result
}
- /** Same as ++
- */
- def concat[B >: A, That](that: Traversable[B])(implicit bf: BuilderFactory[B, That, This]): That = this.++(that)(bf)
- def concat[B >: A, That](that: Iterator[B])(implicit bf: BuilderFactory[B, That, This]): That = this.++(that)(bf)
-
/** Returns the traversable that results from applying the given function
- * <code>f</code> to each element of this traversable and collecing the results
+ * <code>f</code> to each element of this traversable and collecting the results
* in an traversable of type `That`.
*
* @param f function to apply to each element.
- * @return <code>f(a<sub>0</sub>), ..., f(a<sub>n</sub>)</code> if this
- * traversable is <code>a<sub>0</sub>, ..., a<sub>n</sub></code>.
*/
def map[B, That](f: A => B)(implicit bf: BuilderFactory[B, That, This]): That = {
val b = bf(thisCollection)
@@ -105,11 +146,9 @@ self =>
}
/** Applies the given function <code>f</code> to each element of
- * this traversable, then concatenates the results in an traversable of type CC.
+ * this traversable, then concatenates the results in an traversable of type That.
*
* @param f the function to apply on each element.
- * @return <code>f(a<sub>0</sub>) ::: ... ::: f(a<sub>n</sub>)</code> if
- * this traversable is <code>a<sub>0</sub>, ..., a<sub>n</sub></code>.
*/
def flatMap[B, That](f: A => Traversable[B])(implicit bf: BuilderFactory[B, That, This]): That = {
val b = bf(thisCollection)
@@ -181,15 +220,6 @@ self =>
m mapValues (_.result)
}
- /** Apply a function <code>f</code> to all elements of this
- * traversable object.
- *
- * @param f a function that is applied to every element.
- * @note This method underlies the implementation of most other bulk operations.
- * It should be overridden in concrete collection classes with efficient implementations.
- */
- def foreach[B](f: A => B): Unit
-
/** Return true iff the given predicate `p` yields true for all elements
* of this traversable.
*
@@ -384,7 +414,7 @@ self =>
result()
}
- /** Returns as an option the first element of this traversable
+ /** Returns as an option the first element of this traversable
* or <code>None</code> if traversable is empty.
* @note Might return different results for different runs, unless this traversable is ordered
*/
diff --git a/src/library/scala/collection/immutable/List.scala b/src/library/scala/collection/immutable/List.scala
index acfbdc531f..9a205e97c4 100644
--- a/src/library/scala/collection/immutable/List.scala
+++ b/src/library/scala/collection/immutable/List.scala
@@ -493,7 +493,7 @@ object List extends SequenceFactory[List] {
override def empty[A]: List[A] = Nil
- override def apply[A](xs: A*): List[A] = Iterable.fromOld(xs).toList
+ override def apply[A](xs: A*): List[A] = xs.toList
/** Create a sorted list with element values
* <code>v<sub>n+1</sub> = step(v<sub>n</sub>)</code>
@@ -683,8 +683,7 @@ object List extends SequenceFactory[List] {
* @return the string as a list of characters.
* @deprecated use <code>str.toList</code> instead
*/
- @deprecated def fromString(str: String): List[Char] =
- Iterable.fromOld(str).toList
+ @deprecated def fromString(str: String): List[Char] = str.toList
/** Returns the given list of characters as a string.
*
diff --git a/src/library/scala/collection/immutable/ListMap.scala b/src/library/scala/collection/immutable/ListMap.scala
index 98aca89049..5c57715409 100644
--- a/src/library/scala/collection/immutable/ListMap.scala
+++ b/src/library/scala/collection/immutable/ListMap.scala
@@ -74,7 +74,7 @@ class ListMap[A, +B] extends Map[A, B] with ImmutableMapTemplate[A, B, ListMap[A
* @param elems the remaining elements to add.
*/
override def + [B1 >: B] (elem1: (A, B1), elem2: (A, B1), elems: (A, B1) *): ListMap[A, B1] =
- this + elem1 + elem2 ++ collection.Iterable.fromOld(elems)
+ this + elem1 + elem2 ++ elems
/** This creates a new mapping without the given <code>key</code>.
* If the map does not contain a mapping for the given key, the
diff --git a/src/library/scala/collection/immutable/SortedMap.scala b/src/library/scala/collection/immutable/SortedMap.scala
index 2ce558fa00..85461b54c9 100644
--- a/src/library/scala/collection/immutable/SortedMap.scala
+++ b/src/library/scala/collection/immutable/SortedMap.scala
@@ -38,12 +38,6 @@ trait SortedMap[A, +B] extends Map[A, B]
*/
def + [B1 >: B](kv: (A, B1)): SortedMap[A, B1] = throw new AbstractMethodError("SortedMap.+")
- /** Add a key/value pair to this map, returning a new map.
- * @param kv the key/value pair
- * @return A new map with the new binding added to this map
- */
- override def plus [B1 >: B] (kv: (A, B1)): SortedMap[A, B1] = this + kv
-
/** Adds two or more elements to this collection and returns
* a new collection.
*
@@ -54,16 +48,6 @@ trait SortedMap[A, +B] extends Map[A, B]
override def + [B1 >: B] (elem1: (A, B1), elem2: (A, B1), elems: (A, B1) *): SortedMap[A, B1] =
this + elem1 + elem2 ++ elems
- /** Adds two or more elements to this collection and returns
- * a new collection.
- *
- * @param elem1 the first element to add.
- * @param elem2 the second element to add.
- * @param elems the remaining elements to add.
- */
- override def plus [B1 >: B] (elem1: (A, B1), elem2: (A, B1), elems: (A, B1) *): SortedMap[A, B1] =
- this.+(elem1, elem2, elems: _*)
-
/** Adds a number of elements provided by a traversable object
* and returns a new collection with the added elements.
*
@@ -72,18 +56,6 @@ trait SortedMap[A, +B] extends Map[A, B]
override def ++[B1 >: B](elems: collection.Traversable[(A, B1)]): SortedMap[A, B1] =
((thisCollection: SortedMap[A, B1]) /: elems) (_ + _)
- /** Adds a number of elements provided by a traversable object
- * and returns a new collection with the added elements.
- *
- * @param elems the traversable object.
- * @note same as `++`
- * @note This is a more efficient version of Traversable.++ which avoids
- * copying of the collection's elements. However, it applies only if
- * the type of the added elements is a subtype of the element type of the
- * collection.
- */
- override def plusAll [B1 >: B](elems: collection.Traversable[(A, B1)]): SortedMap[A, B1] = this.++(elems)
-
/** Adds a number of elements provided by an iterator
* and returns a new collection with the added elements.
*
@@ -91,18 +63,6 @@ trait SortedMap[A, +B] extends Map[A, B]
*/
override def ++[B1 >: B] (iter: Iterator[(A, B1)]): SortedMap[A, B1] =
((thisCollection: SortedMap[A, B1]) /: iter) (_ + _)
-
- /** Adds a number of elements provided by an iterator
- * and returns a new collection with the added elements.
- *
- * @param iter the iterator
- * @note same as `++`
- * @note This is a more efficient version of Traversable.++ which avoids
- * copying of the collection's elements. However, it applies only if
- * the type of the added elements is a subtype of the element type of the
- * collection.
- */
- override def plusAll [B1 >: B](iter: Iterator[(A, B1)]): SortedMap[A, B1] = this.++(iter)
}
object SortedMap extends ImmutableSortedMapFactory[SortedMap] {
diff --git a/src/library/scala/collection/immutable/Stream.scala b/src/library/scala/collection/immutable/Stream.scala
index 7ac6b78bf4..1c50b59aa8 100644
--- a/src/library/scala/collection/immutable/Stream.scala
+++ b/src/library/scala/collection/immutable/Stream.scala
@@ -392,7 +392,7 @@ object Stream extends SequenceFactory[Stream] {
override def empty[A]: Stream[A] = Empty
/** A stream consisting of given elements */
- override def apply[A](xs: A*): Stream[A] = Iterable.fromOld(xs).toStream
+ override def apply[A](xs: A*): Stream[A] = xs.toStream
/** A wrapper class that adds `#::` for cons and `#:::` for concat as operations
* to streams.
diff --git a/src/library/scala/collection/mutable/LinkedHashSet.scala b/src/library/scala/collection/mutable/LinkedHashSet.scala
index 1b3c9e29fc..089419ccbd 100644
--- a/src/library/scala/collection/mutable/LinkedHashSet.scala
+++ b/src/library/scala/collection/mutable/LinkedHashSet.scala
@@ -19,7 +19,7 @@ object LinkedHashSet {
/** The canonical factory for this type
*/
- def apply[A](elems: A*) = empty[A] ++ collection.Iterable.fromOld(elems)
+ def apply[A](elems: A*) = empty[A] ++= elems
}
@serializable
@@ -52,6 +52,6 @@ class LinkedHashSet[A] extends Set[A] with MutableSetTemplate[A, LinkedHashSet[A
super.clear()
}
- override def elements = Iterator.fromOld(ordered.reverse.elements)
+ override def elements = ordered.reverse.elements
}
diff --git a/src/library/scala/collection/mutable/Queue.scala b/src/library/scala/collection/mutable/Queue.scala
index f4fcab4abf..f42a3d9659 100644
--- a/src/library/scala/collection/mutable/Queue.scala
+++ b/src/library/scala/collection/mutable/Queue.scala
@@ -29,7 +29,7 @@ class Queue[A] extends MutableList[A] with Cloneable[Queue[A]] {
*
* @param elems the elements to add.
*/
- def enqueue(elems: A*): Unit = (this ++= collection.Iterable.fromOld(elems))
+ def enqueue(elems: A*): Unit = this ++= elems
/** Returns the first element in the queue, and removes this element
* from the queue.