diff options
Diffstat (limited to 'src/library')
-rw-r--r-- | src/library/scala/Random.scala | 56 | ||||
-rw-r--r-- | src/library/scala/util/Random.scala | 9 |
2 files changed, 10 insertions, 55 deletions
diff --git a/src/library/scala/Random.scala b/src/library/scala/Random.scala index 4b44466b43..c24e2b2080 100644 --- a/src/library/scala/Random.scala +++ b/src/library/scala/Random.scala @@ -17,59 +17,9 @@ package scala * @deprecated 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. */ +class Random(self: java.util.Random) extends util.Random(self) { 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) } - + def this() = this(new java.util.Random()) } + diff --git a/src/library/scala/util/Random.scala b/src/library/scala/util/Random.scala index 021d0c182b..e37cb477ba 100644 --- a/src/library/scala/util/Random.scala +++ b/src/library/scala/util/Random.scala @@ -24,7 +24,7 @@ class Random(val self: java.util.Random) { def this(seed: Int) = this(seed.toLong) /** Creates a new random number generator. */ - def this() = this(compat.Platform.currentTime) + def this() = this(new java.util.Random()) /** Returns the next pseudorandom, uniformly distributed boolean value * from this random number generator's sequence. @@ -50,6 +50,7 @@ class Random(val self: java.util.Random) { * double value with mean 0.0 and standard deviation 1.0 from this * random number generator's sequence. */ + // XXX why is this the only method of java.util.Random to be commented out? //def nextGaussian(): Double = self.nextGaussian() /** Returns the next pseudorandom, uniformly distributed int value @@ -69,5 +70,9 @@ class Random(val self: java.util.Random) { def nextLong(): Long = self.nextLong() def setSeed(seed: Long) { self.setSeed(seed) } - } + +/** The object <code>Random</code> offers a default implementation + * of scala.util.Random. + */ +object Random extends Random
\ No newline at end of file |