summaryrefslogtreecommitdiff
path: root/src/library
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2009-11-09 18:34:49 +0000
committerMartin Odersky <odersky@gmail.com>2009-11-09 18:34:49 +0000
commit7da30bf2d5195d1e7a156680b50167707f7a3d0a (patch)
tree083cd78a70a13ac5fab4609a2a2875be48501df0 /src/library
parent2aeae987765bd5a63954b89ac8428db97b0a369f (diff)
downloadscala-7da30bf2d5195d1e7a156680b50167707f7a3d0a.tar.gz
scala-7da30bf2d5195d1e7a156680b50167707f7a3d0a.tar.bz2
scala-7da30bf2d5195d1e7a156680b50167707f7a3d0a.zip
added `locally' to Predef.
added overloaded hashes to Predef. some small changes.
Diffstat (limited to 'src/library')
-rw-r--r--src/library/scala/Predef.scala12
-rw-r--r--src/library/scala/collection/mutable/BufferProxy.scala4
2 files changed, 16 insertions, 0 deletions
diff --git a/src/library/scala/Predef.scala b/src/library/scala/Predef.scala
index df6cc61ee6..c3e0548183 100644
--- a/src/library/scala/Predef.scala
+++ b/src/library/scala/Predef.scala
@@ -91,11 +91,23 @@ object Predef extends LowPriorityImplicits {
def currentThread = java.lang.Thread.currentThread()
+ @inline def locally[T](x: T): T = x
+
// hashcode -----------------------------------------------------------
@inline def hash(x: Any): Int =
if (x.isInstanceOf[Number]) runtime.BoxesRunTime.numHash(x.asInstanceOf[Number]) else x.hashCode
+ @inline def hash(x: Number): Int =
+ runtime.BoxesRunTime.numHash(x.asInstanceOf[Number])
+
+ @inline def hash(x: Long): Int = {
+ val iv = x.intValue
+ if (iv == x.longValue) iv else x.hashCode
+ }
+
+ @inline def hash(x: Int): Int = x
+
// errors and asserts -------------------------------------------------
def error(message: String): Nothing = throw new RuntimeException(message)
diff --git a/src/library/scala/collection/mutable/BufferProxy.scala b/src/library/scala/collection/mutable/BufferProxy.scala
index 343233e351..a31beda57b 100644
--- a/src/library/scala/collection/mutable/BufferProxy.scala
+++ b/src/library/scala/collection/mutable/BufferProxy.scala
@@ -40,6 +40,8 @@ trait BufferProxy[A] extends Buffer[A] with Proxy {
* @param elem the element to append.
* @return the updated buffer.
*/
+ @deprecated("Use += instead if you intend to add by side effect to an existing collection.\n"+
+ "Use `clone() ++=' if you intend to create a new collection.")
override def +(elem: A): Buffer[A] = self.+(elem)
/** Append a single element to this buffer.
@@ -57,6 +59,8 @@ trait BufferProxy[A] extends Buffer[A] with Proxy {
* @param iter the iterable object.
* @return the updated buffer.
*/
+ @deprecated("Use ++= instead if you intend to add by side effect to an existing collection.\n"+
+ "Use `clone() ++=` if you intend to create a new collection.")
def ++(iter: scala.collection.Iterable[A]): Buffer[A] = self.++(iter)
/** Appends a number of elements provided by an iterable object