summaryrefslogtreecommitdiff
path: root/src/library
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2009-11-19 04:59:46 +0000
committerPaul Phillips <paulp@improving.org>2009-11-19 04:59:46 +0000
commit6f4e82da32eec2d1be861c8e4ca442d11b9a86cf (patch)
treea338985093fbb0f9fd020cb7f43a646c73501fdb /src/library
parent2a6a02e9a782b7621e3dc79d2f07fca074b11bb6 (diff)
downloadscala-6f4e82da32eec2d1be861c8e4ca442d11b9a86cf.tar.gz
scala-6f4e82da32eec2d1be861c8e4ca442d11b9a86cf.tar.bz2
scala-6f4e82da32eec2d1be861c8e4ca442d11b9a86cf.zip
Restoring an embarassingly large quantity of de...
Restoring an embarassingly large quantity of deprecated methods whose time had not yet come.
Diffstat (limited to 'src/library')
-rw-r--r--src/library/scala/Array.scala42
-rw-r--r--src/library/scala/Either.scala32
-rw-r--r--src/library/scala/Product.scala3
-rw-r--r--src/library/scala/collection/IterableLike.scala5
-rw-r--r--src/library/scala/collection/SeqLike.scala7
-rw-r--r--src/library/scala/collection/SetLike.scala8
-rw-r--r--src/library/scala/collection/immutable/List.scala62
-rw-r--r--src/library/scala/collection/immutable/TreeHashMap.scala2
-rw-r--r--src/library/scala/collection/mutable/StringBuilder.scala35
9 files changed, 196 insertions, 0 deletions
diff --git a/src/library/scala/Array.scala b/src/library/scala/Array.scala
index a9f07157a0..a323dccffc 100644
--- a/src/library/scala/Array.scala
+++ b/src/library/scala/Array.scala
@@ -397,6 +397,48 @@ object Array extends FallbackArrayBuilding {
}
a
}
+
+ /** Create an array containing the values of a given function <code>f</code>
+ * over given range <code>[0..n)</code>
+ */
+ @deprecated("use `Array.tabulate' instead")
+ def fromFunction[T: ClassManifest](f: Int => T)(n: Int): Array[T] = {
+ val a = new Array[T](n)
+ var i = 0
+ while (i < n) {
+ a(i) = f(i)
+ i += 1
+ }
+ a
+ }
+
+ /** Create an array containing the values of a given function <code>f</code>
+ * over given range <code>[0..n1, 0..n2)</code>
+ */
+ @deprecated("use `Array.tabulate' instead")
+ def fromFunction[T: ClassManifest](f: (Int, Int) => T)(n1: Int, n2: Int): Array[Array[T]] =
+ fromFunction(i => fromFunction(f(i, _))(n2))(n1)
+
+ /** Create an array containing the values of a given function <code>f</code>
+ * over given range <code>[0..n1, 0..n2, 0..n3)</code>
+ */
+ @deprecated("use `Array.tabulate' instead")
+ def fromFunction[T: ClassManifest](f: (Int, Int, Int) => T)(n1: Int, n2: Int, n3: Int): Array[Array[Array[T]]] =
+ fromFunction(i => fromFunction(f(i, _, _))(n2, n3))(n1)
+
+ /** Create an array containing the values of a given function <code>f</code>
+ * over given range <code>[0..n1, 0..n2, 0..n3, 0..n4)</code>
+ */
+ @deprecated("use `Array.tabulate' instead")
+ def fromFunction[T: ClassManifest](f: (Int, Int, Int, Int) => T)(n1: Int, n2: Int, n3: Int, n4: Int): Array[Array[Array[Array[T]]]] =
+ fromFunction(i => fromFunction(f(i, _, _, _))(n2, n3, n4))(n1)
+
+ /** Create an array containing the values of a given function <code>f</code>
+ * over given range <code>[0..n1, 0..n2, 0..n3, 0..n4, 0..n5)</code>
+ */
+ @deprecated("use `Array.tabulate' instead")
+ def fromFunction[T: ClassManifest](f: (Int, Int, Int, Int, Int) => T)(n1: Int, n2: Int, n3: Int, n4: Int, n5: Int): Array[Array[Array[Array[Array[T]]]]] =
+ fromFunction(i => fromFunction(f(i, _, _, _, _))(n2, n3, n4, n5))(n1)
}
/** This class represents polymorphic arrays. <code>Array[T]</code> is Scala's representation
diff --git a/src/library/scala/Either.scala b/src/library/scala/Either.scala
index e456dab2dd..cc84685287 100644
--- a/src/library/scala/Either.scala
+++ b/src/library/scala/Either.scala
@@ -328,6 +328,38 @@ object Either {
case Right(t) => t
}
+ /**
+ * Returns the <code>Left</code> values in the given <code>Iterable</code> of <code>Either</code>s.
+ */
+ @deprecated("use `for (Left(a) <- es) yield a'")
+ def lefts[A, B](es: Iterable[Either[A, B]]) =
+ es.foldRight[List[A]](Nil)((e, as) => e match {
+ case Left(a) => a :: as
+ case Right(_) => as
+ })
+
+ /**
+ * Returns the <code>Right</code> values in the given<code>Iterable</code> of <code>Either</code>s.
+ */
+ @deprecated("use `for (Right(a) <- es) yield a'")
+ def rights[A, B](es: Iterable[Either[A, B]]) =
+ es.foldRight[List[B]](Nil)((e, bs) => e match {
+ case Left(_) => bs
+ case Right(b) => b :: bs
+ })
+
+ /** Transforms an Iterable of Eithers into a pair of lists.
+ *
+ * @param xs the iterable of Eithers to separate
+ * @return a pair of lists.
+ */
+ @deprecated("use `for ((Left(l), Right(r)) <- es partition isLeft) yield (l, r)'")
+ def separate[A,B](es: Iterable[Either[A,B]]): (List[A], List[B]) =
+ es.foldRight[(List[A], List[B])]((Nil, Nil)) {
+ case (Left(a), (lefts, rights)) => (a :: lefts, rights)
+ case (Right(b), (lefts, rights)) => (lefts, b :: rights)
+ }
+
/** If the condition satisfies, return the given A in <code>Left</code>,
* otherwise, return the given B in <code>Right</code>.
*/
diff --git a/src/library/scala/Product.scala b/src/library/scala/Product.scala
index a9ced34768..ce8f733771 100644
--- a/src/library/scala/Product.scala
+++ b/src/library/scala/Product.scala
@@ -41,6 +41,9 @@ trait Product extends Equals {
def next() = { val result = productElement(c); c += 1; result }
}
+ @deprecated("use productIterator instead")
+ def productElements: Iterator[Any] = productIterator
+
/**
* By default the empty string. Implementations may override this
* method in order to prepend a string prefix to the result of the
diff --git a/src/library/scala/collection/IterableLike.scala b/src/library/scala/collection/IterableLike.scala
index 1a17c9b7b0..2946426748 100644
--- a/src/library/scala/collection/IterableLike.scala
+++ b/src/library/scala/collection/IterableLike.scala
@@ -360,6 +360,11 @@ self =>
*/
override def view(from: Int, until: Int) = view.slice(from, until)
+ @deprecated("use `head' instead") def first: A = head
+
+ /** <code>None</code> if iterable is empty. */
+ @deprecated("use `headOption' instead") def firstOption: Option[A] = headOption
+
/**
* returns a projection that can be used to call non-strict <code>filter</code>,
* <code>map</code>, and <code>flatMap</code> methods that build projections
diff --git a/src/library/scala/collection/SeqLike.scala b/src/library/scala/collection/SeqLike.scala
index 65b4bb016c..661f7b7a04 100644
--- a/src/library/scala/collection/SeqLike.scala
+++ b/src/library/scala/collection/SeqLike.scala
@@ -293,6 +293,9 @@ trait SeqLike[+A, +Repr] extends IterableLike[A, Repr] { self =>
*/
def reverseIterator: Iterator[A] = toCollection(reverse).iterator
+ @deprecated("use `reverseIterator' instead")
+ def reversedElements = reverseIterator
+
/**
* Checks whether the argument sequence is contained at the
* specified index within the receiver object.
@@ -610,6 +613,10 @@ trait SeqLike[+A, +Repr] extends IterableLike[A, Repr] { self =>
*/
override def toString = super[IterableLike].toString
+ /** Returns index of the last element satisying a predicate, or -1. */
+ @deprecated("use `lastIndexWhere' instead")
+ def findLastIndexOf(p: A => Boolean): Int = lastIndexWhere(p)
+
@deprecated("Should be replaced by <code>(s1, s2) forall { case (x, y) => f(x, y) }</code>")
def equalsWith[B](that: Seq[B])(f: (A,B) => Boolean): Boolean = {
val i = this.iterator
diff --git a/src/library/scala/collection/SetLike.scala b/src/library/scala/collection/SetLike.scala
index 0b123b0c90..0752f4185f 100644
--- a/src/library/scala/collection/SetLike.scala
+++ b/src/library/scala/collection/SetLike.scala
@@ -105,6 +105,14 @@ self =>
*/
def &(that: Set[A]): This = intersect(that)
+ /** This method is an alias for <code>intersect</code>.
+ * It computes an intersection with set <code>that</code>.
+ * It removes all the elements that are not present in <code>that</code>.
+ *
+ * @param that the set to intersect with
+ */
+ @deprecated("use & instead") def ** (that: Set[A]): This = intersect(that)
+
/** The union of this set and the given set <code>that</code>.
*
* @param that the set of elements to add
diff --git a/src/library/scala/collection/immutable/List.scala b/src/library/scala/collection/immutable/List.scala
index 8c43bdb998..3287204c58 100644
--- a/src/library/scala/collection/immutable/List.scala
+++ b/src/library/scala/collection/immutable/List.scala
@@ -555,6 +555,68 @@ object List extends SeqFactory[List] {
b.toList
}
+ /** Transforms a list of pairs into a pair of lists.
+ *
+ * @param xs the list of pairs to unzip
+ * @return a pair of lists.
+ */
+ @deprecated("use `xs.unzip' instead")
+ def unzip[A,B](xs: List[(A,B)]): (List[A], List[B]) = {
+ val b1 = new ListBuffer[A]
+ val b2 = new ListBuffer[B]
+ var xc = xs
+ while (!xc.isEmpty) {
+ b1 += xc.head._1
+ b2 += xc.head._2
+ xc = xc.tail
+ }
+ (b1.toList, b2.toList)
+ }
+
+ /** Transforms an iterable of pairs into a pair of lists.
+ *
+ * @param xs the iterable of pairs to unzip
+ * @return a pair of lists.
+ */
+ @deprecated("use `xs.unzip' instead")
+ def unzip[A,B](xs: Iterable[(A,B)]): (List[A], List[B]) =
+ xs.foldRight[(List[A], List[B])]((Nil, Nil)) {
+ case ((x, y), (xs, ys)) => (x :: xs, y :: ys)
+ }
+
+ /**
+ * Returns the <code>Left</code> values in the given <code>Iterable</code>
+ * of <code>Either</code>s.
+ */
+ @deprecated("use `Either.lefts' instead")
+ def lefts[A, B](es: Iterable[Either[A, B]]) =
+ es.foldRight[List[A]](Nil)((e, as) => e match {
+ case Left(a) => a :: as
+ case Right(_) => as
+ })
+
+ /**
+ * Returns the <code>Right</code> values in the given<code>Iterable</code> of <code>Either</code>s.
+ */
+ @deprecated("use `Either.rights' instead")
+ def rights[A, B](es: Iterable[Either[A, B]]) =
+ es.foldRight[List[B]](Nil)((e, bs) => e match {
+ case Left(_) => bs
+ case Right(b) => b :: bs
+ })
+
+ /** Transforms an Iterable of Eithers into a pair of lists.
+ *
+ * @param xs the iterable of Eithers to separate
+ * @return a pair of lists.
+ */
+ @deprecated("use `Either.separate' instead")
+ def separate[A,B](es: Iterable[Either[A,B]]): (List[A], List[B]) =
+ es.foldRight[(List[A], List[B])]((Nil, Nil)) {
+ case (Left(a), (lefts, rights)) => (a :: lefts, rights)
+ case (Right(b), (lefts, rights)) => (lefts, b :: rights)
+ }
+
/** Converts an iterator to a list.
*
* @param it the iterator to convert
diff --git a/src/library/scala/collection/immutable/TreeHashMap.scala b/src/library/scala/collection/immutable/TreeHashMap.scala
index 6b4f728925..d991df196f 100644
--- a/src/library/scala/collection/immutable/TreeHashMap.scala
+++ b/src/library/scala/collection/immutable/TreeHashMap.scala
@@ -177,6 +177,8 @@ private[collection] sealed abstract class AssocMap[Key, +Value] extends immutabl
def iterator : Iterator[(Key, Value)] = new AssocMapIterator(this)
+ @deprecated("use `iterator' instead") def elements = iterator
+
override final def foreach[U](f : ((Key, Value)) => U) = this match {
case Cons(key, value, tail) => { f((key, value)); tail.foreach(f); }
case Nil() => {}
diff --git a/src/library/scala/collection/mutable/StringBuilder.scala b/src/library/scala/collection/mutable/StringBuilder.scala
index b216e24c5d..47bac8ad47 100644
--- a/src/library/scala/collection/mutable/StringBuilder.scala
+++ b/src/library/scala/collection/mutable/StringBuilder.scala
@@ -92,6 +92,11 @@ final class StringBuilder(initCapacity: Int, private val initValue: String)
*/
def capacity: Int = array.length
+ /** Same as <code>ensureCapacity</code>. */
+ @deprecated("use `ensureCapacity' instead. An assignment is misleading because\n"+
+ "it can never decrease the capacity.")
+ def capacity_=(n: Int) { ensureCapacity(n) }
+
/** <p>
* Ensures that the capacity is at least equal to the specified minimum.
* If the current capacity is less than the argument, then a new internal
@@ -292,6 +297,11 @@ final class StringBuilder(initCapacity: Int, private val initValue: String)
def appendAll(x: Seq[Char]): StringBuilder =
appendAll(x.toArray, 0, x.length)
+ @deprecated("use appendAll instead. This method is deprecated because of the\n"+
+ "possible confusion with `append(Any)'.")
+ def append(x: Seq[Char]): StringBuilder =
+ appendAll(x)
+
/** <p>
* Appends the string representation of the <code>Char</code> array
* argument to this sequence.
@@ -308,6 +318,11 @@ final class StringBuilder(initCapacity: Int, private val initValue: String)
def appendAll(x: Array[Char]): StringBuilder =
appendAll(x, 0, x.length)
+ @deprecated("use appendAll instead. This method is deprecated because\n"+
+ "of the possible confusion with `append(Any)'.")
+ def append(x: Array[Char]): StringBuilder =
+ appendAll(x)
+
/** <p>
* Appends the string representation of a subarray of the
* <code>char</code> array argument to this sequence.
@@ -331,6 +346,11 @@ final class StringBuilder(initCapacity: Int, private val initValue: String)
this
}
+ @deprecated("use appendAll instead. This method is deprecated because\n"+
+ "of the possible confusion with `append(Any, Int, Int)'.")
+ def append(x: Array[Char], offset: Int, len: Int): StringBuilder =
+ appendAll(x, offset, len)
+
/** <p>
* Appends the string representation of the <code>Boolean</code>
* argument to the sequence.
@@ -458,6 +478,11 @@ final class StringBuilder(initCapacity: Int, private val initValue: String)
this
}
+ @deprecated("use insertAll instead. This method is deprecated because of the\n"+
+ "possible confusion with `insert(Int, Any, Int, Int)'.")
+ def insert(index: Int, str: Array[Char], offset: Int, len: Int): StringBuilder =
+ insertAll(index, str, offset, len)
+
/** <p>
* Inserts the string representation of the <code>Any</code>
* argument into this character sequence.
@@ -512,6 +537,11 @@ final class StringBuilder(initCapacity: Int, private val initValue: String)
def insertAll(at: Int, x: Seq[Char]): StringBuilder =
insertAll(at, x.toArray)
+ @deprecated("use insertAll instead. This method is deprecated because of\n"+
+ "the possible confusion with `insert(Int, Any)'.")
+ def insert(at: Int, x: Seq[Char]): StringBuilder =
+ insertAll(at, x)
+
/** Inserts the string representation of the <code>Char</code> array
* argument into this sequence.
*
@@ -531,6 +561,11 @@ final class StringBuilder(initCapacity: Int, private val initValue: String)
this
}
+ @deprecated("use insertAll instead. This method is deprecated because of\n"+
+ "the possible confusion with `insert(Int, Any)'.")
+ def insert(at: Int, x: Array[Char]): StringBuilder =
+ insertAll(at, x)
+
/** <p>
* Inserts the string representation of the <code>Boolean</code> argument
* into this sequence.