random.scala
来自「JAVA 语言的函数式编程扩展」· SCALA 代码 · 共 73 行
SCALA
73 行
/* __ *\** ________ ___ / / ___ Scala API **** / __/ __// _ | / / / _ | (c) 2006-2007, LAMP/EPFL **** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **** /____/\___/_/ |_/____/_/ | | **** |/ **\* */// $Id: Random.scala 14531 2008-04-07 12:15:54Z washburn $package scala/** * @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) } }
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?