summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormichelou <michelou@epfl.ch>2008-07-29 13:19:54 +0000
committermichelou <michelou@epfl.ch>2008-07-29 13:19:54 +0000
commit2513754bd52bc09b9060d1c967548867fda4cc3e (patch)
tree08670d29cd91eeafc7bfa6bb45fd556d71391b2a
parent71fd0c5ed0ad11ada531ed3b3250f0e547f98c57 (diff)
downloadscala-2513754bd52bc09b9060d1c967548867fda4cc3e.tar.gz
scala-2513754bd52bc09b9060d1c967548867fda4cc3e.tar.bz2
scala-2513754bd52bc09b9060d1c967548867fda4cc3e.zip
moved class Random to package scala.util
-rw-r--r--src/library/scala/Random.scala5
-rw-r--r--src/library/scala/util/Properties.scala1
-rw-r--r--src/library/scala/util/Random.scala73
3 files changed, 78 insertions, 1 deletions
diff --git a/src/library/scala/Random.scala b/src/library/scala/Random.scala
index c1e8801bf4..bc7c1961a6 100644
--- a/src/library/scala/Random.scala
+++ b/src/library/scala/Random.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2006-2007, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2006-2008, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
@@ -13,7 +13,10 @@ package scala
/**
* @author Stephane Micheloud
+ *
+ * Use class <code>scala.util.Random</code> instead.
*/
+@deprecated
class Random(val self: java.util.Random) {
/** Creates a new random number generator using a single long seed. */
diff --git a/src/library/scala/util/Properties.scala b/src/library/scala/util/Properties.scala
index 2fa885dc3a..6100d3bac9 100644
--- a/src/library/scala/util/Properties.scala
+++ b/src/library/scala/util/Properties.scala
@@ -8,6 +8,7 @@
// $Id$
+
package scala.util
/** A utility to load the library properties from a Java properties file
diff --git a/src/library/scala/util/Random.scala b/src/library/scala/util/Random.scala
new file mode 100644
index 0000000000..ef6b066bd8
--- /dev/null
+++ b/src/library/scala/util/Random.scala
@@ -0,0 +1,73 @@
+/* __ *\
+** ________ ___ / / ___ Scala API **
+** / __/ __// _ | / / / _ | (c) 2006-2008, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
+** /____/\___/_/ |_/____/_/ | | **
+** |/ **
+\* */
+
+// $Id: $
+
+
+package scala.util
+
+/**
+ * @author Stephane Micheloud
+ *
+ */
+class Random(val self: java.util.Random) {
+
+ /** Creates a new random number generator using a single long seed. */
+ def this(seed: Long) = this(new java.util.Random(seed))
+
+ /** Creates a new random number generator using a single integer seed. */
+ def this(seed: Int) = this(seed.toLong)
+
+ /** Creates a new random number generator. */
+ def this() = this(compat.Platform.currentTime)
+
+ /** Returns the next pseudorandom, uniformly distributed boolean value
+ * from this random number generator's sequence.
+ */
+ def nextBoolean(): Boolean = self.nextBoolean()
+
+ /** Generates random bytes and places them into a user-supplied byte
+ * array.
+ */
+ def nextBytes(bytes: Array[Byte]) { self.nextBytes(bytes) }
+
+ /** Returns the next pseudorandom, uniformly distributed double value
+ * between 0.0 and 1.0 from this random number generator's sequence.
+ */
+ def nextDouble(): Double = self.nextDouble()
+
+ /** Returns the next pseudorandom, uniformly distributed float value
+ * between 0.0 and 1.0 from this random number generator's sequence.
+ */
+ def nextFloat(): Float = self.nextFloat()
+
+ /** Returns the next pseudorandom, Gaussian ("normally") distributed
+ * double value with mean 0.0 and standard deviation 1.0 from this
+ * random number generator's sequence.
+ */
+ //def nextGaussian(): Double = self.nextGaussian()
+
+ /** Returns the next pseudorandom, uniformly distributed int value
+ * from this random number generator's sequence.
+ */
+ def nextInt(): Int = self.nextInt()
+
+ /** Returns a pseudorandom, uniformly distributed int value between 0
+ * (inclusive) and the specified value (exclusive), drawn from this
+ * random number generator's sequence.
+ */
+ def nextInt(n: Int): Int = self.nextInt(n)
+
+ /** Returns the next pseudorandom, uniformly distributed long value
+ * from this random number generator's sequence.
+ */
+ def nextLong(): Long = self.nextLong()
+
+ def setSeed(seed: Long) { self.setSeed(seed) }
+
+}