Generator

abstract class Generator
Companion:
object
class Object
trait Matchable
class Any

Value members

Abstract methods

def nextInt(): Int

Generate an equally-distributed random Int.

Generate an equally-distributed random Int.

def nextLong(): Long

Generates a random long. All 64-bit long values are equally likely.

Generates a random long. All 64-bit long values are equally likely.

def setSeedBytes(bytes: Array[Byte]): Unit

Concrete methods

def chooseFromArray[@specialized A](arr: Array[A])(implicit gen: Generator): A
def chooseFromIterable[A](as: Iterable[A])(implicit gen: Generator): A
def chooseFromSeq[A](seq: Seq[A])(implicit gen: Generator): A
def fillArray[@specialized A : Dist](arr: Array[A]): Unit

Fill an Array[A] using the given Dist[A] instance.

Fill an Array[A] using the given Dist[A] instance.

def fillBytes(arr: Array[Byte]): Unit

Fill an array with random Bytes.

Fill an array with random Bytes.

def fillGaussians(arr: Array[Double], mean: Double, stddev: Double): Unit
def fillInts(arr: Array[Int]): Unit

Fill an array with random Ints.

Fill an array with random Ints.

def fillLongs(arr: Array[Long]): Unit

Fill an array with random Longs.

Fill an array with random Longs.

Fill an array with random Shorts.

Fill an array with random Shorts.

Generate an Array[A] using the given Dist[A] instance.

Generate an Array[A] using the given Dist[A] instance.

Generate an array of n random Bytes.

Generate an array of n random Bytes.

def generateGaussians(n: Int, mean: Double, stddev: Double): Array[Double]

Generate an array of n random Ints.

Generate an array of n random Ints.

Generate an array of n random Longs.

Generate an array of n random Longs.

Generate an array of n random Shorts.

Generate an array of n random Shorts.

def iterator[A](implicit next: Dist[A]): Iterator[A]

Generate an infinite iterator of random values using Dist[A].

Generate an infinite iterator of random values using Dist[A].

def next[A](implicit next: Dist[A]): A

Generate a random value using a Dist[A] type class instance.

Generate a random value using a Dist[A] type class instance.

Implicit Dist[A] instances are provided for the AnyVal types as well as UByte through ULong. More complex Dist instances can be created from these.

def nextBits(n: Int): Int

Generates a random integer using n bits of state (0 <= n <= 32).

Generates a random integer using n bits of state (0 <= n <= 32).

Generates a random Boolean.

Generates a random Boolean.

Generates a random double in [0.0, 1.0).

Generates a random double in [0.0, 1.0).

Generates a random double in [0.0, n).

Generates a random double in [0.0, n).

def nextDouble(from: Double, until: Double): Double

Generates a random double in [from, until).

Generates a random double in [from, until).

Generates a random float in [0.0, 1.0).

Generates a random float in [0.0, 1.0).

Generates a random float in [0.0, n).

Generates a random float in [0.0, n).

def nextFloat(from: Float, until: Float): Float

Generates a random float in [from, until).

Generates a random float in [from, until).

def nextGaussian(mean: Double, stddev: Double): Double
def nextInt(n: Int): Int

Generates a random int between 0 (inclusive) and n (exclusive).

Generates a random int between 0 (inclusive) and n (exclusive).

def nextInt(from: Int, to: Int): Int

Return an Int in [from, to].

Return an Int in [from, to].

def nextLong(n: Long): Long

Generates a random int between 0 (inclusive) and n (exclusive).

Generates a random int between 0 (inclusive) and n (exclusive).

def nextLong(from: Long, to: Long): Long

Return an Long in [from, to].

Return an Long in [from, to].

def oneOf[A](as: A*): A
def sampleFromArray[@specialized A : ClassTag](as: Array[A], size: Int)(implicit evidence$4: ClassTag[A], gen: Generator): Array[A]
def sampleFromIterable[@specialized A : ClassTag](as: Iterable[A], size: Int)(implicit evidence$5: ClassTag[A], gen: Generator): Array[A]
def shuffle[@specialized A](as: Array[A])(implicit gen: Generator): Unit

Deprecated methods

@deprecated("use sampleFromIterable instead", since = "0.18.0")
def sampleFromTraversable[@specialized A : ClassTag](as: Iterable[A], size: Int)(implicit evidence$6: ClassTag[A], gen: Generator): Array[A]
Deprecated
[Since version 0.18.0]