diff options
author | Geoffrey Washburn <geoffrey.washburn@epfl.ch> | 2008-05-19 12:50:31 +0000 |
---|---|---|
committer | Geoffrey Washburn <geoffrey.washburn@epfl.ch> | 2008-05-19 12:50:31 +0000 |
commit | 7b33fcff437ff18f31b81a61d45a1fcf8ed75d5c (patch) | |
tree | eea6f44906d27fd2aa74ba8cb1dd64c3b904501a /src/library | |
parent | 639ce2f29dfded08e27d5e909b85b653a1567e51 (diff) | |
download | scala-7b33fcff437ff18f31b81a61d45a1fcf8ed75d5c.tar.gz scala-7b33fcff437ff18f31b81a61d45a1fcf8ed75d5c.tar.bz2 scala-7b33fcff437ff18f31b81a61d45a1fcf8ed75d5c.zip |
Deprecate all of the problematic + methods, and...
Deprecate all of the problematic + methods, and removed those that never
appeared in a release.
Diffstat (limited to 'src/library')
-rw-r--r-- | src/library/scala/List.scala | 4 | ||||
-rw-r--r-- | src/library/scala/RandomAccessSeq.scala | 3 | ||||
-rw-r--r-- | src/library/scala/Seq.scala | 3 | ||||
-rw-r--r-- | src/library/scala/collection/immutable/Queue.scala | 29 | ||||
-rw-r--r-- | src/library/scala/collection/immutable/Stack.scala | 25 |
5 files changed, 53 insertions, 11 deletions
diff --git a/src/library/scala/List.scala b/src/library/scala/List.scala index 2bb49e652e..2486aac041 100644 --- a/src/library/scala/List.scala +++ b/src/library/scala/List.scala @@ -486,10 +486,12 @@ sealed abstract class List[+A] extends Seq[A] { * Add an element <code>x</code> at the end of this list. * </p> * + * @deprecated Replace uses of <code>l + e</code> with <code>l ::: List(e)</code>. + * * @param x the element to append. * @return the list with <code>x</code> added at the end. */ - override def +[B >: A](x: B): List[B] = + @deprecated def +[B >: A](x: B): List[B] = if (isEmpty) List(x) else { val buf = new ListBuffer[B] diff --git a/src/library/scala/RandomAccessSeq.scala b/src/library/scala/RandomAccessSeq.scala index 18b2beb0d6..437d7ae8fb 100644 --- a/src/library/scala/RandomAccessSeq.scala +++ b/src/library/scala/RandomAccessSeq.scala @@ -205,9 +205,6 @@ trait RandomAccessSeq[+A] extends Seq[A] { buf.readOnly } - override def +[B >: A](e: B): RandomAccessSeq[B] = - this ++ Seq.single(e) - override def toStream : Stream[A] = new Stream.Definite[A] { override def isEmpty = RandomAccessSeq.this.isEmpty override def head = RandomAccessSeq.this.apply(0) diff --git a/src/library/scala/Seq.scala b/src/library/scala/Seq.scala index b49b24ebe8..d43f2d9586 100644 --- a/src/library/scala/Seq.scala +++ b/src/library/scala/Seq.scala @@ -213,9 +213,6 @@ trait Seq[+A] extends AnyRef with PartialFunction[Int, A] with Collection[A] { buf.readOnly } - def +[B >: A](e: B): Seq[B] = - this ++ Seq.single(e) - /** Is this partial function defined for the index <code>x</code>? * * @param x .. diff --git a/src/library/scala/collection/immutable/Queue.scala b/src/library/scala/collection/immutable/Queue.scala index 01abc1a813..bb481f263a 100644 --- a/src/library/scala/collection/immutable/Queue.scala +++ b/src/library/scala/collection/immutable/Queue.scala @@ -70,9 +70,34 @@ class Queue[+A](elem: A*) extends Seq[A] { /** Creates a new queue with element added at the end * of the old queue. * + * @deprecated Use the method <code>enqueue</code> from now on. + * * @param elem the element to insert */ - override def +[B >: A](elem: B) = mkQueue(elem :: in, out) + @deprecated def +[B >: A](elem: B) = mkQueue(elem :: in, out) + + /** Creates a new queue with element added at the end + * of the old queue. + * + * @param elem the element to insert + */ + def enqueue[B >: A](elem: B) = mkQueue(elem :: in, out) + + /** Returns a new queue with all all elements provided by + * an <code>Iterable</code> object added at the end of + * the queue. + * The elements are prepended in the order they + * are given out by the iterator. + * + * @deprecated Use the method <code>enqueue</code> from now on. + * + * @param iter an iterable object + */ + @deprecated def +[B >: A](iter: Iterable[B]) = { + var q: List[B] = in + iter.elements.foreach(e => q = e :: q) + mkQueue(q, out) + } /** Returns a new queue with all all elements provided by * an <code>Iterable</code> object added at the end of @@ -82,7 +107,7 @@ class Queue[+A](elem: A*) extends Seq[A] { * * @param iter an iterable object */ - def +[B >: A](iter: Iterable[B]) = { + def enqueue[B >: A](iter: Iterable[B]) = { var q: List[B] = in iter.elements.foreach(e => q = e :: q) mkQueue(q, out) diff --git a/src/library/scala/collection/immutable/Stack.scala b/src/library/scala/collection/immutable/Stack.scala index dcff24b51c..dfcb3823df 100644 --- a/src/library/scala/collection/immutable/Stack.scala +++ b/src/library/scala/collection/immutable/Stack.scala @@ -43,10 +43,31 @@ class Stack[+A] extends Seq[A] { /** Push an element on the stack. * + * @deprecated Use the method <code>push</code> from now on. + * * @param elem the element to push on the stack. * @return the stack with the new element on top. */ - override def +[B >: A](elem: B): Stack[B] = new Node(elem) + @deprecated def +[B >: A](elem: B): Stack[B] = new Node(elem) + + /** Push an element on the stack. + * + * @param elem the element to push on the stack. + * @return the stack with the new element on top. + */ + def push[B >: A](elem: B): Stack[B] = new Node(elem) + + /** Push all elements provided by the given iterable object onto + * the stack. The last element returned by the iterable object + * will be on top of the new stack. + * + * @deprecated Use the method <code>push</code> from now on. + * + * @param elems the iterable object. + * @return the stack with the new elements on top. + */ + @deprecated def +[B >: A](elems: Iterable[B]): Stack[B] = + elems.foldLeft(this: Stack[B]){ (stack, elem) => stack + elem } /** Push all elements provided by the given iterable object onto * the stack. The last element returned by the iterable object @@ -55,7 +76,7 @@ class Stack[+A] extends Seq[A] { * @param elems the iterable object. * @return the stack with the new elements on top. */ - def +[B >: A](elems: Iterable[B]): Stack[B] = + def push[B >: A](elems: Iterable[B]): Stack[B] = elems.foldLeft(this: Stack[B]){ (stack, elem) => stack + elem } /** Push a sequence of elements onto the stack. The last element |