diff options
author | Paul Phillips <paulp@improving.org> | 2009-11-20 15:16:45 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2009-11-20 15:16:45 +0000 |
commit | f7b8e8f346fed1d8128976db959bff7001ed1d57 (patch) | |
tree | 59f18491ee87c9f33922b510f071f27013b355a6 /src/library | |
parent | 99d8d53c36cb2283df9d42b25273aeba594e82b5 (diff) | |
download | scala-f7b8e8f346fed1d8128976db959bff7001ed1d57.tar.gz scala-f7b8e8f346fed1d8128976db959bff7001ed1d57.tar.bz2 scala-f7b8e8f346fed1d8128976db959bff7001ed1d57.zip |
More world-shaking deprecation work.
object, updating some @deprecated messages to give realistic
alternatives, properly resolving the semantic mismatch between List.--
and diff, its once-recommended but inequivalent alternative.
Diffstat (limited to 'src/library')
-rw-r--r-- | src/library/scala/collection/TraversableViewLike.scala | 3 | ||||
-rw-r--r-- | src/library/scala/collection/immutable/HashMap.scala | 2 | ||||
-rw-r--r-- | src/library/scala/collection/immutable/HashSet.scala | 2 | ||||
-rw-r--r-- | src/library/scala/collection/immutable/List.scala | 2 | ||||
-rw-r--r-- | src/library/scala/collection/immutable/NumericRange.scala | 8 | ||||
-rw-r--r-- | src/library/scala/collection/immutable/PagedSeq.scala | 2 | ||||
-rw-r--r-- | src/library/scala/collection/immutable/Range.scala | 2 | ||||
-rw-r--r-- | src/library/scala/collection/immutable/Vector.scala | 6 | ||||
-rw-r--r-- | src/library/scala/collection/mutable/IndexedSeqView.scala | 3 | ||||
-rw-r--r-- | src/library/scala/collection/mutable/StringBuilder.scala | 6 | ||||
-rw-r--r-- | src/library/scala/math/Ordering.scala | 6 | ||||
-rw-r--r-- | src/library/scala/math/package.scala | 33 | ||||
-rw-r--r-- | src/library/scala/runtime/RichDouble.scala | 16 | ||||
-rw-r--r-- | src/library/scala/runtime/RichFloat.scala | 16 | ||||
-rw-r--r-- | src/library/scala/util/Sorting.scala | 16 |
15 files changed, 65 insertions, 58 deletions
diff --git a/src/library/scala/collection/TraversableViewLike.scala b/src/library/scala/collection/TraversableViewLike.scala index 8177658026..0c214d956c 100644 --- a/src/library/scala/collection/TraversableViewLike.scala +++ b/src/library/scala/collection/TraversableViewLike.scala @@ -13,7 +13,6 @@ package scala.collection import generic._ import mutable.Builder -import Math.MAX_INT import TraversableView.NoBuilder /** <p> @@ -167,7 +166,7 @@ self => override def filter(p: A => Boolean): This = newFiltered(p).asInstanceOf[This] override def init: This = newSliced(0, size - 1).asInstanceOf[This] - override def drop(n: Int): This = newSliced(n max 0, MAX_INT).asInstanceOf[This] + override def drop(n: Int): This = newSliced(n max 0, Int.MaxValue).asInstanceOf[This] override def take(n: Int): This = newSliced(0, n).asInstanceOf[This] override def slice(from: Int, until: Int): This = newSliced(from max 0, until).asInstanceOf[This] override def dropWhile(p: A => Boolean): This = newDroppedWhile(p).asInstanceOf[This] diff --git a/src/library/scala/collection/immutable/HashMap.scala b/src/library/scala/collection/immutable/HashMap.scala index 64608d163f..a036a9abfb 100644 --- a/src/library/scala/collection/immutable/HashMap.scala +++ b/src/library/scala/collection/immutable/HashMap.scala @@ -122,7 +122,7 @@ class HashMap[A, +B] extends Map[A,B] with MapLike[A, B, HashMap[A, B]] with mut private def getValue(e: Entry) = e.value.asInstanceOf[B] - private def logLimit: Int = Math.sqrt(table.length).toInt + private def logLimit: Int = math.sqrt(table.length).toInt private[this] def markUpdated(key: A, ov: Option[B], delta: Int) { val lv = loadFactor diff --git a/src/library/scala/collection/immutable/HashSet.scala b/src/library/scala/collection/immutable/HashSet.scala index 93b9678751..e55469d173 100644 --- a/src/library/scala/collection/immutable/HashSet.scala +++ b/src/library/scala/collection/immutable/HashSet.scala @@ -96,7 +96,7 @@ class HashSet[A] extends Set[A] cached.iterator } - private def logLimit: Int = Math.sqrt(table.length).toInt + private def logLimit: Int = math.sqrt(table.length).toInt private def markUpdated(elem: A, del: Boolean) { val lv = loadFactor diff --git a/src/library/scala/collection/immutable/List.scala b/src/library/scala/collection/immutable/List.scala index 4eb2d4ccf1..0c43620465 100644 --- a/src/library/scala/collection/immutable/List.scala +++ b/src/library/scala/collection/immutable/List.scala @@ -306,7 +306,7 @@ sealed abstract class List[+A] extends LinearSeq[A] * @return this list without the elements of the given list * <code>that</code>. */ - @deprecated("use `list1.toSet -- list2` instead") + @deprecated("use `list1 filterNot (list2 contains)` instead") def -- [B >: A](that: List[B]): List[B] = { val b = new ListBuffer[B] var these = this diff --git a/src/library/scala/collection/immutable/NumericRange.scala b/src/library/scala/collection/immutable/NumericRange.scala index 9c70ba3ca6..67b097e65d 100644 --- a/src/library/scala/collection/immutable/NumericRange.scala +++ b/src/library/scala/collection/immutable/NumericRange.scala @@ -25,7 +25,7 @@ import generic._ * the Int-based scala.Range should be more performant. * </p><pre> * <b>val</b> r1 = new Range(0, 100, 1) - * <b>val</b> veryBig = Math.MAX_INT.toLong + 1 + * <b>val</b> veryBig = Int.MaxValue.toLong + 1 * <b>val</b> r2 = Range.Long(veryBig, veryBig + 100, 1) * assert(r1 sameElements r2.map(_ - veryBig)) * </pre> @@ -48,9 +48,9 @@ extends IndexedSeq[T] // todo? - we could lift the length restriction by implementing a range as a sequence of // subranges and limiting the subranges to MAX_INT. There's no other way around it because // the generics we inherit assume integer-based indexing (as well they should.) - // The second condition is making sure type T can meaningfully be compared to Math.MAX_INT. - if (genericLength > fromInt(Math.MAX_INT) && (Math.MAX_INT == toInt(fromInt(Math.MAX_INT)))) - fail("Implementation restricts ranges to Math.MAX_INT elements.") + // The second condition is making sure type T can meaningfully be compared to Int.MaxValue. + if (genericLength > fromInt(Int.MaxValue) && (Int.MaxValue == toInt(fromInt(Int.MaxValue)))) + fail("Implementation restricts ranges to Int.MaxValue elements.") // inclusive/exclusiveness captured this way because we do not have any // concept of a "unit", we can't just add an epsilon to an exclusive diff --git a/src/library/scala/collection/immutable/PagedSeq.scala b/src/library/scala/collection/immutable/PagedSeq.scala index 08979ac347..fadf21f819 100644 --- a/src/library/scala/collection/immutable/PagedSeq.scala +++ b/src/library/scala/collection/immutable/PagedSeq.scala @@ -21,7 +21,7 @@ import scala.util.matching.Regex * @since 2.7 */ object PagedSeq { - final val UndeterminedEnd = Math.MAX_INT + final val UndeterminedEnd = Int.MaxValue /** Constructs a character sequence from a character iterator */ def fromIterator[T: ClassManifest](source: Iterator[T]): PagedSeq[T] = diff --git a/src/library/scala/collection/immutable/Range.scala b/src/library/scala/collection/immutable/Range.scala index 651c03a5d9..831ea2c678 100644 --- a/src/library/scala/collection/immutable/Range.scala +++ b/src/library/scala/collection/immutable/Range.scala @@ -138,7 +138,7 @@ object Range { class Inclusive(start: Int, end: Int, step: Int) extends Range(start, end, step) { override def isInclusive = true - override protected val limit = end + Math.signum(step) + override protected val limit = end + math.signum(step) override protected def copy(start: Int, end: Int, step: Int): Range = new Inclusive(start, end, step) } diff --git a/src/library/scala/collection/immutable/Vector.scala b/src/library/scala/collection/immutable/Vector.scala index e0a73fe427..eeccac2d7d 100644 --- a/src/library/scala/collection/immutable/Vector.scala +++ b/src/library/scala/collection/immutable/Vector.scala @@ -564,7 +564,7 @@ final class VectorIterator[+A](_startIndex: Int, _endIndex: Int) extends Iterato private var lo: Int = _startIndex & 31 private var endIndex: Int = _endIndex - private var endLo = Math.min(endIndex - blockIndex, 32) + private var endLo = math.min(endIndex - blockIndex, 32) def hasNext = _hasNext @@ -582,7 +582,7 @@ final class VectorIterator[+A](_startIndex: Int, _endIndex: Int) extends Iterato gotoNextBlockStart(newBlockIndex, blockIndex ^ newBlockIndex) blockIndex = newBlockIndex - endLo = Math.min(endIndex - blockIndex, 32) + endLo = math.min(endIndex - blockIndex, 32) lo = 0 } else { _hasNext = false @@ -1011,7 +1011,7 @@ private[immutable] trait VectorPointer[T] { final def copyRange(array: Array[AnyRef], oldLeft: Int, newLeft: Int) = { val elems = new Array[AnyRef](32) - Platform.arraycopy(array, oldLeft, elems, newLeft, 32 - Math.max(newLeft,oldLeft)) + Platform.arraycopy(array, oldLeft, elems, newLeft, 32 - math.max(newLeft,oldLeft)) elems } diff --git a/src/library/scala/collection/mutable/IndexedSeqView.scala b/src/library/scala/collection/mutable/IndexedSeqView.scala index 77b8862421..ca952bfbaa 100644 --- a/src/library/scala/collection/mutable/IndexedSeqView.scala +++ b/src/library/scala/collection/mutable/IndexedSeqView.scala @@ -13,7 +13,6 @@ package scala.collection package mutable import generic._ -import Math.MAX_INT import TraversableView.NoBuilder @@ -79,7 +78,7 @@ self => override def filter(p: A => Boolean): IndexedSeqView[A, Coll] = newFiltered(p) override def init: IndexedSeqView[A, Coll] = newSliced(0, size - 1).asInstanceOf[IndexedSeqView[A, Coll]] - override def drop(n: Int): IndexedSeqView[A, Coll] = newSliced(n max 0, MAX_INT).asInstanceOf[IndexedSeqView[A, Coll]] + override def drop(n: Int): IndexedSeqView[A, Coll] = newSliced(n max 0, Int.MaxValue).asInstanceOf[IndexedSeqView[A, Coll]] override def take(n: Int): IndexedSeqView[A, Coll] = newSliced(0, n).asInstanceOf[IndexedSeqView[A, Coll]] override def slice(from: Int, until: Int): IndexedSeqView[A, Coll] = newSliced(from max 0, until).asInstanceOf[IndexedSeqView[A, Coll]] override def dropWhile(p: A => Boolean): IndexedSeqView[A, Coll] = newDroppedWhile(p).asInstanceOf[IndexedSeqView[A, Coll]] diff --git a/src/library/scala/collection/mutable/StringBuilder.scala b/src/library/scala/collection/mutable/StringBuilder.scala index 67d74ab1fd..e83a30b180 100644 --- a/src/library/scala/collection/mutable/StringBuilder.scala +++ b/src/library/scala/collection/mutable/StringBuilder.scala @@ -727,7 +727,7 @@ final class StringBuilder(initCapacity: Int, private val initValue: String) * specified substring, starting at the specified index. The integer * returned is the smallest value <code>k</code> for which: * </p><pre> - * k >= Math.min(fromIndex, str.length()) && + * k >= math.min(fromIndex, str.length()) && * this.toString().startsWith(str, k)</pre> * <p> * If no such value of <code>k</code> exists, then <code>-1</code> @@ -768,7 +768,7 @@ final class StringBuilder(initCapacity: Int, private val initValue: String) * specified substring. The integer returned is the largest value * <code>k</code> such that: * </p><pre>val - * k <= Math.min(fromIndex, str.length()) && + * k <= math.min(fromIndex, str.length()) && * this.toString().startsWith(str, k)</pre> * <p> * If no such value of <code>k</code> exists, then <code>-1</code> @@ -852,7 +852,7 @@ object StringBuilder // method <code>java.util.Arrays.copyOf</code> exists since 1.6 private def copyOf(src: Array[Char], newLength: Int): Array[Char] = { val dest = new Array[Char](newLength) - arraycopy(src, 0, dest, 0, Math.min(src.length, newLength)) + arraycopy(src, 0, dest, 0, src.length min newLength) dest } } diff --git a/src/library/scala/math/Ordering.scala b/src/library/scala/math/Ordering.scala index 30e13d9f0e..3eeebc8aea 100644 --- a/src/library/scala/math/Ordering.scala +++ b/src/library/scala/math/Ordering.scala @@ -27,11 +27,11 @@ import java.util.Comparator * <li>reflexive: <code>compare(x, x) == 0</code>, for any <code>x</code> of * type <code>T</code>.</li> * <li>symmetry: <code>compare(x, y) == z</code> and <code>compare(y, x) == w</code> - * then <code>Math.signum(z) == -Math.signum(w)</code>, for any <code>x</code> and <code>y</code> of + * then <code>math.signum(z) == -math.signum(w)</code>, for any <code>x</code> and <code>y</code> of * type <code>T</code> and <code>z</code> and <code>w</code> of type <code>Int</code>.</li> * <li>transitive: if <code>compare(x, y) == z</code> and <code>compare(y, w) == v</code> - * and <code>Math.signum(z) >= 0</code> and <code>Math.signum(v) >= 0</code> then - * <code>compare(x, w) == u</code> and <code>Math.signum(z + v) == Math.signum(u)</code>, + * and <code>math.signum(z) >= 0</code> and <code>math.signum(v) >= 0</code> then + * <code>compare(x, w) == u</code> and <code>math.signum(z + v) == math.signum(u)</code>, * for any <code>x</code>, <code>y</code>, * and <code>w</code> of type <code>T</code> and <code>z</code>, <code>v</code>, and <code>u</code> * of type <code>Int</code>.</li> diff --git a/src/library/scala/math/package.scala b/src/library/scala/math/package.scala index 51c657893b..7f34f1fe99 100644 --- a/src/library/scala/math/package.scala +++ b/src/library/scala/math/package.scala @@ -171,18 +171,27 @@ package object math { def min(x: Float, y: Float): Float = java.lang.Math.min(x, y) def min(x: Double, y: Double): Double = java.lang.Math.min(x, y) - def signum(x: Double): Double = x match { case 0 => 0 - case y if y < 0 => -1.0 - case y if y > 0 => 1.0 } - def signum(x: Float): Float = x match { case 0f => 0f - case y if y < 0f => -1.0f - case y if y > 0f => 1.0f } - def signum(x: Long): Long = x match { case 0l => 0l - case y if y < 0l => -1l - case y if y > 0l => 1l } - def signum(x: Int): Int = x match { case 0 => 0 - case y if y < 0 => -1 - case y if y > 0 => 1} + def signum(x: Double): Double = + if (x == 0d) 0d + else if (x < 0) -1.0 + else if (x > 0) 1.0 + else x // NaN + + def signum(x: Float): Float = + if (x == 0f) 0f + else if (x < 0) -1.0f + else if (x > 0) 1.0f + else x // NaN + + def signum(x: Long): Long = + if (x == 0l) 0l + else if (x < 0) -1l + else 1l + + def signum(x: Int): Int = + if (x == 0) 0 + else if (x < 0) -1 + else 1 // from Java 1.5 // def log10(x: Double): Double = java.lang.Math.log10(x) diff --git a/src/library/scala/runtime/RichDouble.scala b/src/library/scala/runtime/RichDouble.scala index d30cd899a2..8d2203f9a5 100644 --- a/src/library/scala/runtime/RichDouble.scala +++ b/src/library/scala/runtime/RichDouble.scala @@ -19,13 +19,13 @@ final class RichDouble(x: Double) extends Proxy with Ordered[Double] { def compare(y: Double): Int = java.lang.Double.compare(x, y) - def min(y: Double): Double = Math.min(x, y) - def max(y: Double): Double = Math.max(x, y) - def abs: Double = Math.abs(x) + def min(y: Double): Double = math.min(x, y) + def max(y: Double): Double = math.max(x, y) + def abs: Double = math.abs(x) - def round: Long = Math.round(x) - def ceil: Double = Math.ceil(x) - def floor: Double = Math.floor(x) + def round: Long = math.round(x) + def ceil: Double = math.ceil(x) + def floor: Double = math.floor(x) /** See <code>BigDecimal.until</code>. */ def until(end: Double): Range.Partial[Double, NumericRange[Double]] = @@ -49,7 +49,7 @@ final class RichDouble(x: Double) extends Proxy with Ordered[Double] { * @param x an angle, in degrees * @return the measurement of the angle <code>x</code> in radians. */ - def toRadians: Double = Math.toRadians(x) + def toRadians: Double = math.toRadians(x) /** Converts an angle measured in radians to an approximately equivalent * angle measured in degrees @@ -57,7 +57,7 @@ final class RichDouble(x: Double) extends Proxy with Ordered[Double] { * @param x angle, in radians * @return the measurement of the angle <code>x</code> in degrees. */ - def toDegrees: Double = Math.toDegrees(x) + def toDegrees: Double = math.toDegrees(x) // isNaN is provided by the implicit conversion to java.lang.Double // def isNaN: Boolean = java.lang.Double.isNaN(x) diff --git a/src/library/scala/runtime/RichFloat.scala b/src/library/scala/runtime/RichFloat.scala index ac47dcc934..7a547f083c 100644 --- a/src/library/scala/runtime/RichFloat.scala +++ b/src/library/scala/runtime/RichFloat.scala @@ -21,13 +21,13 @@ final class RichFloat(x: Float) extends Proxy with Ordered[Float] { //def compare(y: Float): Int = if (x < y) -1 else if (x > y) 1 else 0 def compare(y: Float): Int = java.lang.Float.compare(x, y) - def min(y: Float) = Math.min(x, y) - def max(y: Float) = Math.max(x, y) - def abs: Float = Math.abs(x) + def min(y: Float) = math.min(x, y) + def max(y: Float) = math.max(x, y) + def abs: Float = math.abs(x) - def round: Int = Math.round(x) - def ceil: Float = Math.ceil(x).toFloat - def floor: Float = Math.floor(x).toFloat + def round: Int = math.round(x) + def ceil: Float = math.ceil(x).toFloat + def floor: Float = math.floor(x).toFloat /** Converts an angle measured in degrees to an approximately equivalent * angle measured in radians. @@ -35,7 +35,7 @@ final class RichFloat(x: Float) extends Proxy with Ordered[Float] { * @param x an angle, in degrees * @return the measurement of the angle <code>x</code> in radians. */ - def toRadians: Float = Math.toRadians(x).toFloat + def toRadians: Float = math.toRadians(x).toFloat /** Converts an angle measured in radians to an approximately equivalent * angle measured in degrees. @@ -43,7 +43,7 @@ final class RichFloat(x: Float) extends Proxy with Ordered[Float] { * @param x angle, in radians * @return the measurement of the angle <code>x</code> in degrees. */ - def toDegrees: Float = Math.toDegrees(x).toFloat + def toDegrees: Float = math.toDegrees(x).toFloat // isNaN is provided by the implicit conversion to java.lang.Float // def isNaN: Boolean = java.lang.Float.isNaN(x) diff --git a/src/library/scala/util/Sorting.scala b/src/library/scala/util/Sorting.scala index a7c83a5f43..73228b53d5 100644 --- a/src/library/scala/util/Sorting.scala +++ b/src/library/scala/util/Sorting.scala @@ -174,9 +174,9 @@ object Sorting { // Swap partition elements back to middle val n = off + len - var s = Math.min(a-off, b-a) + var s = math.min(a-off, b-a) vecswap(off, b-s, s) - s = Math.min(d-c, n-d-1) + s = math.min(d-c, n-d-1) vecswap(b, n-s, s) // Recursively sort non-partition-elements @@ -275,9 +275,9 @@ object Sorting { // Swap partition elements back to middle val n = off + len - var s = Math.min(a-off, b-a) + var s = math.min(a-off, b-a) vecswap(off, b-s, s) - s = Math.min(d-c, n-d-1) + s = math.min(d-c, n-d-1) vecswap(b, n-s, s) // Recursively sort non-partition-elements @@ -383,9 +383,9 @@ object Sorting { // Swap partition elements back to middle val n = off + len - var s = Math.min(a-off, b-a) + var s = math.min(a-off, b-a) vecswap(off, b-s, s) - s = Math.min(d-c, n-d-1) + s = math.min(d-c, n-d-1) vecswap(b, n-s, s) // Recursively sort non-partition-elements @@ -491,9 +491,9 @@ object Sorting { // Swap partition elements back to middle val n = off + len - var s = Math.min(a-off, b-a) + var s = math.min(a-off, b-a) vecswap(off, b-s, s) - s = Math.min(d-c, n-d-1) + s = math.min(d-c, n-d-1) vecswap(b, n-s, s) // Recursively sort non-partition-elements |