org.scalatest.prop

Randomizer

class Randomizer extends AnyRef

Provide random values, of many different types.

This is loosely inspired by java.util.Random (and is designed to produce the same values in conventional cases), with two major differences:

On the first of those points, this returns many data types, including many of the tightly-defined numeric types from Scalactic. These allow you to put tight constraints on precisely what numbers you want to have available -- positive, negative, zeroes, infinities and so on. We strongly recommend that you use the function that most exactly describes the values you are looking for.

That second point is the more important one. You shouldn't call the same Randomizer over and over, the way you would do in Java. Instead, each call to a Randomizer function returns the next Randomizer, which you should use for the next call.

If you are using random floating-point values: the algorithms in use here produce random values across the potential space of values. But due to the way floating-point works, this means that these values are strongly biased towards small numbers. There are many floating-point numbers with negative exponents, so you may get more numbers in the range between -1 and 1 than you expect.

Self Type
Randomizer
Source
Randomizer.scala
Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Randomizer
  2. AnyRef
  3. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Instance Constructors

  1. new Randomizer(seed: Long)

    seed

Value Members

  1. final def !=(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

    Definition Classes
    AnyRef → Any
  4. final def ==(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  5. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  6. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  7. def chooseByte(from: Byte, to: Byte): (Byte, Randomizer)

    Given a range of Bytes, chooses one of them randomly.

    Given a range of Bytes, chooses one of them randomly.

    Note that, while the from parameter is usually smaller than to, that is not required; the function will cope appropriately if they are in reverse order.

    The choice is inclusive: either the from or to values may be returned.

    from

    One end of the range to select from.

    to

    The other end of the range.

    returns

    A value from that range, inclusive of the ends.

  8. def chooseChar(from: Char, to: Char): (Char, Randomizer)

    Given a range of Chars, chooses one of them randomly.

    Given a range of Chars, chooses one of them randomly.

    Note that, while the from parameter is usually smaller than to, that is not required; the function will cope appropriately if they are in reverse order.

    The choice is inclusive: either the from or to values may be returned.

    from

    One end of the range to select from.

    to

    The other end of the range.

    returns

    A value from that range, inclusive of the ends.

  9. def chooseDouble(from: Double, to: Double): (Double, Randomizer)

    Given a range of Doubles, chooses one of them randomly.

    Given a range of Doubles, chooses one of them randomly.

    Note that, while the from parameter is usually smaller than to, that is not required; the function will cope appropriately if they are in reverse order.

    The choice is inclusive: either the from or to values may be returned.

    from

    One end of the range to select from.

    to

    The other end of the range.

    returns

    A value from that range, inclusive of the ends.

  10. def chooseFiniteDouble(from: FiniteDouble, to: FiniteDouble): (FiniteDouble, Randomizer)

    Given a range of finite Doubles, chooses one of them randomly.

    Given a range of finite Doubles, chooses one of them randomly.

    Note that, while the from parameter is usually smaller than to, that is not required; the function will cope appropriately if they are in reverse order.

    The choice is inclusive: either the from or to values may be returned.

    from

    One end of the range to select from.

    to

    The other end of the range.

    returns

    A value from that range, inclusive of the ends.

  11. def chooseFiniteFloat(from: FiniteFloat, to: FiniteFloat): (FiniteFloat, Randomizer)

    Given a range of finite Floats, chooses one of them randomly.

    Given a range of finite Floats, chooses one of them randomly.

    Note that, while the from parameter is usually smaller than to, that is not required; the function will cope appropriately if they are in reverse order.

    The choice is inclusive: either the from or to values may be returned.

    from

    One end of the range to select from.

    to

    The other end of the range.

    returns

    A value from that range, inclusive of the ends.

  12. def chooseFloat(from: Float, to: Float): (Float, Randomizer)

    Given a range of Floats, chooses one of them randomly.

    Given a range of Floats, chooses one of them randomly.

    Note that, while the from parameter is usually smaller than to, that is not required; the function will cope appropriately if they are in reverse order.

    The choice is inclusive: either the from or to values may be returned.

    from

    One end of the range to select from.

    to

    The other end of the range.

    returns

    A value from that range, inclusive of the ends.

  13. def chooseInt(from: Int, to: Int): (Int, Randomizer)

    Given a range of Ints, chooses one of them randomly.

    Given a range of Ints, chooses one of them randomly.

    Note that, while the from parameter is usually smaller than to, that is not required; the function will cope appropriately if they are in reverse order.

    The choice is inclusive: either the from or to values may be returned.

    from

    One end of the range to select from.

    to

    The other end of the range.

    returns

    A value from that range, inclusive of the ends.

  14. def chooseLong(from: Long, to: Long): (Long, Randomizer)

    Given a range of Longs, chooses one of them randomly.

    Given a range of Longs, chooses one of them randomly.

    Note that, while the from parameter is usually smaller than to, that is not required; the function will cope appropriately if they are in reverse order.

    The choice is inclusive: either the from or to values may be returned.

    from

    One end of the range to select from.

    to

    The other end of the range.

    returns

    A value from that range, inclusive of the ends.

  15. def chooseNegDouble(from: NegDouble, to: NegDouble): (NegDouble, Randomizer)

    Given a range of negative Doubles, chooses one of them randomly.

    Given a range of negative Doubles, chooses one of them randomly.

    Note that, while the from parameter is usually smaller than to, that is not required; the function will cope appropriately if they are in reverse order.

    The choice is inclusive: either the from or to values may be returned.

    from

    One end of the range to select from.

    to

    The other end of the range.

    returns

    A value from that range, inclusive of the ends.

  16. def chooseNegFiniteDouble(from: NegFiniteDouble, to: NegFiniteDouble): (NegFiniteDouble, Randomizer)

    Given a range of negative, finite Doubles, chooses one of them randomly.

    Given a range of negative, finite Doubles, chooses one of them randomly.

    Note that, while the from parameter is usually smaller than to, that is not required; the function will cope appropriately if they are in reverse order.

    The choice is inclusive: either the from or to values may be returned.

    from

    One end of the range to select from.

    to

    The other end of the range.

    returns

    A value from that range, inclusive of the ends.

  17. def chooseNegFiniteFloat(from: NegFiniteFloat, to: NegFiniteFloat): (NegFiniteFloat, Randomizer)

    Given a range of negative, finite Floats, chooses one of them randomly.

    Given a range of negative, finite Floats, chooses one of them randomly.

    Note that, while the from parameter is usually smaller than to, that is not required; the function will cope appropriately if they are in reverse order.

    The choice is inclusive: either the from or to values may be returned.

    from

    One end of the range to select from.

    to

    The other end of the range.

    returns

    A value from that range, inclusive of the ends.

  18. def chooseNegFloat(from: NegFloat, to: NegFloat): (NegFloat, Randomizer)

    Given a range of negative Floats, chooses one of them randomly.

    Given a range of negative Floats, chooses one of them randomly.

    Note that, while the from parameter is usually smaller than to, that is not required; the function will cope appropriately if they are in reverse order.

    The choice is inclusive: either the from or to values may be returned.

    from

    One end of the range to select from.

    to

    The other end of the range.

    returns

    A value from that range, inclusive of the ends.

  19. def chooseNegInt(from: NegInt, to: NegInt): (NegInt, Randomizer)

    Given a range of negative Ints, chooses one of them randomly.

    Given a range of negative Ints, chooses one of them randomly.

    Note that, while the from parameter is usually smaller than to, that is not required; the function will cope appropriately if they are in reverse order.

    The choice is inclusive: either the from or to values may be returned.

    from

    One end of the range to select from.

    to

    The other end of the range.

    returns

    A value from that range, inclusive of the ends.

  20. def chooseNegLong(from: NegLong, to: NegLong): (NegLong, Randomizer)

    Given a range of negative Longs, chooses one of them randomly.

    Given a range of negative Longs, chooses one of them randomly.

    Note that, while the from parameter is usually smaller than to, that is not required; the function will cope appropriately if they are in reverse order.

    The choice is inclusive: either the from or to values may be returned.

    from

    One end of the range to select from.

    to

    The other end of the range.

    returns

    A value from that range, inclusive of the ends.

  21. def chooseNegZDouble(from: NegZDouble, to: NegZDouble): (NegZDouble, Randomizer)

    Given a range of negative Doubles (maybe including zero), chooses one of them randomly.

    Given a range of negative Doubles (maybe including zero), chooses one of them randomly.

    Note that, while the from parameter is usually smaller than to, that is not required; the function will cope appropriately if they are in reverse order.

    The choice is inclusive: either the from or to values may be returned.

    from

    One end of the range to select from.

    to

    The other end of the range.

    returns

    A value from that range, inclusive of the ends.

  22. def chooseNegZFiniteDouble(from: NegZFiniteDouble, to: NegZFiniteDouble): (NegZFiniteDouble, Randomizer)

    Given a range of negative, finite Doubles (maybe including zero), chooses one of them randomly.

    Given a range of negative, finite Doubles (maybe including zero), chooses one of them randomly.

    Note that, while the from parameter is usually smaller than to, that is not required; the function will cope appropriately if they are in reverse order.

    The choice is inclusive: either the from or to values may be returned.

    from

    One end of the range to select from.

    to

    The other end of the range.

    returns

    A value from that range, inclusive of the ends.

  23. def chooseNegZFiniteFloat(from: NegZFiniteFloat, to: NegZFiniteFloat): (NegZFiniteFloat, Randomizer)

    Given a range of negative, finite Floats (maybe including zero), chooses one of them randomly.

    Given a range of negative, finite Floats (maybe including zero), chooses one of them randomly.

    Note that, while the from parameter is usually smaller than to, that is not required; the function will cope appropriately if they are in reverse order.

    The choice is inclusive: either the from or to values may be returned.

    from

    One end of the range to select from.

    to

    The other end of the range.

    returns

    A value from that range, inclusive of the ends.

  24. def chooseNegZFloat(from: NegZFloat, to: NegZFloat): (NegZFloat, Randomizer)

    Given a range of negative Floats (maybe including zero), chooses one of them randomly.

    Given a range of negative Floats (maybe including zero), chooses one of them randomly.

    Note that, while the from parameter is usually smaller than to, that is not required; the function will cope appropriately if they are in reverse order.

    The choice is inclusive: either the from or to values may be returned.

    from

    One end of the range to select from.

    to

    The other end of the range.

    returns

    A value from that range, inclusive of the ends.

  25. def chooseNegZInt(from: NegZInt, to: NegZInt): (NegZInt, Randomizer)

    Given a range of negative Ints (maybe including zero), chooses one of them randomly.

    Given a range of negative Ints (maybe including zero), chooses one of them randomly.

    Note that, while the from parameter is usually smaller than to, that is not required; the function will cope appropriately if they are in reverse order.

    The choice is inclusive: either the from or to values may be returned.

    from

    One end of the range to select from.

    to

    The other end of the range.

    returns

    A value from that range, inclusive of the ends.

  26. def chooseNegZLong(from: NegZLong, to: NegZLong): (NegZLong, Randomizer)

    Given a range of negative Longs (maybe including zero), chooses one of them randomly.

    Given a range of negative Longs (maybe including zero), chooses one of them randomly.

    Note that, while the from parameter is usually smaller than to, that is not required; the function will cope appropriately if they are in reverse order.

    The choice is inclusive: either the from or to values may be returned.

    from

    One end of the range to select from.

    to

    The other end of the range.

    returns

    A value from that range, inclusive of the ends.

  27. def chooseNonZeroDouble(from: NonZeroDouble, to: NonZeroDouble): (NonZeroDouble, Randomizer)

    Given a range of Doubles (excluding zero), chooses one of them randomly.

    Given a range of Doubles (excluding zero), chooses one of them randomly.

    Note that, while the from parameter is usually smaller than to, that is not required; the function will cope appropriately if they are in reverse order.

    In order to avoid returning 0, this function is very slightly biased towards returning 1 instead.

    The choice is inclusive: either the from or to values may be returned.

    from

    One end of the range to select from.

    to

    The other end of the range.

    returns

    A value from that range, inclusive of the ends.

  28. def chooseNonZeroFiniteDouble(from: NonZeroFiniteDouble, to: NonZeroFiniteDouble): (NonZeroFiniteDouble, Randomizer)

    Given a range of finite Doubles (excluding zero), chooses one of them randomly.

    Given a range of finite Doubles (excluding zero), chooses one of them randomly.

    Note that, while the from parameter is usually smaller than to, that is not required; the function will cope appropriately if they are in reverse order.

    In order to avoid returning 0, this function is very slightly biased towards returning 1 instead.

    The choice is inclusive: either the from or to values may be returned.

    from

    One end of the range to select from.

    to

    The other end of the range.

    returns

    A value from that range, inclusive of the ends.

  29. def chooseNonZeroFiniteFloat(from: NonZeroFiniteFloat, to: NonZeroFiniteFloat): (NonZeroFiniteFloat, Randomizer)

    Given a range of finite Floats (excluding zero), chooses one of them randomly.

    Given a range of finite Floats (excluding zero), chooses one of them randomly.

    Note that, while the from parameter is usually smaller than to, that is not required; the function will cope appropriately if they are in reverse order.

    In order to avoid returning 0, this function is very slightly biased towards returning 1 instead.

    The choice is inclusive: either the from or to values may be returned.

    from

    One end of the range to select from.

    to

    The other end of the range.

    returns

    A value from that range, inclusive of the ends.

  30. def chooseNonZeroFloat(from: NonZeroFloat, to: NonZeroFloat): (NonZeroFloat, Randomizer)

    Given a range of Floats (excluding zero), chooses one of them randomly.

    Given a range of Floats (excluding zero), chooses one of them randomly.

    Note that, while the from parameter is usually smaller than to, that is not required; the function will cope appropriately if they are in reverse order.

    In order to avoid returning 0, this function is very slightly biased towards returning 1 instead.

    The choice is inclusive: either the from or to values may be returned.

    from

    One end of the range to select from.

    to

    The other end of the range.

    returns

    A value from that range, inclusive of the ends.

  31. def chooseNonZeroInt(from: NonZeroInt, to: NonZeroInt): (NonZeroInt, Randomizer)

    Given a range of Ints (excluding zero), chooses one of them randomly.

    Given a range of Ints (excluding zero), chooses one of them randomly.

    Note that, while the from parameter is usually smaller than to, that is not required; the function will cope appropriately if they are in reverse order.

    In order to avoid returning 0, this function is very slightly biased towards returning 1 instead.

    The choice is inclusive: either the from or to values may be returned.

    from

    One end of the range to select from.

    to

    The other end of the range.

    returns

    A value from that range, inclusive of the ends.

  32. def chooseNonZeroLong(from: NonZeroLong, to: NonZeroLong): (NonZeroLong, Randomizer)

    Given a range of Longs (excluding zero), chooses one of them randomly.

    Given a range of Longs (excluding zero), chooses one of them randomly.

    Note that, while the from parameter is usually smaller than to, that is not required; the function will cope appropriately if they are in reverse order.

    In order to avoid returning 0, this function is very slightly biased towards returning 1 instead.

    The choice is inclusive: either the from or to values may be returned.

    from

    One end of the range to select from.

    to

    The other end of the range.

    returns

    A value from that range, inclusive of the ends.

  33. def choosePosDouble(from: PosDouble, to: PosDouble): (PosDouble, Randomizer)

    Given a range of positive Doubles, chooses one of them randomly.

    Given a range of positive Doubles, chooses one of them randomly.

    Note that, while the from parameter is usually smaller than to, that is not required; the function will cope appropriately if they are in reverse order.

    The choice is inclusive: either the from or to values may be returned.

    from

    One end of the range to select from.

    to

    The other end of the range.

    returns

    A value from that range, inclusive of the ends.

  34. def choosePosFiniteDouble(from: PosFiniteDouble, to: PosFiniteDouble): (PosFiniteDouble, Randomizer)

    Given a range of positive finite Doubles, chooses one of them randomly.

    Given a range of positive finite Doubles, chooses one of them randomly.

    Note that, while the from parameter is usually smaller than to, that is not required; the function will cope appropriately if they are in reverse order.

    The choice is inclusive: either the from or to values may be returned.

    from

    One end of the range to select from.

    to

    The other end of the range.

    returns

    A value from that range, inclusive of the ends.

  35. def choosePosFiniteFloat(from: PosFiniteFloat, to: PosFiniteFloat): (PosFiniteFloat, Randomizer)

    Given a range of positive, finite Floats, chooses one of them randomly.

    Given a range of positive, finite Floats, chooses one of them randomly.

    Note that, while the from parameter is usually smaller than to, that is not required; the function will cope appropriately if they are in reverse order.

    The choice is inclusive: either the from or to values may be returned.

    from

    One end of the range to select from.

    to

    The other end of the range.

    returns

    A value from that range, inclusive of the ends.

  36. def choosePosFloat(from: PosFloat, to: PosFloat): (PosFloat, Randomizer)

    Given a range of positive Floats, chooses one of them randomly.

    Given a range of positive Floats, chooses one of them randomly.

    Note that, while the from parameter is usually smaller than to, that is not required; the function will cope appropriately if they are in reverse order.

    The choice is inclusive: either the from or to values may be returned.

    from

    One end of the range to select from.

    to

    The other end of the range.

    returns

    A value from that range, inclusive of the ends.

  37. def choosePosInt(from: PosInt, to: PosInt): (PosInt, Randomizer)

    Given a range of positive Ints, chooses one of them randomly.

    Given a range of positive Ints, chooses one of them randomly.

    Note that, while the from parameter is usually smaller than to, that is not required; the function will cope appropriately if they are in reverse order.

    The choice is inclusive: either the from or to values may be returned.

    from

    One end of the range to select from.

    to

    The other end of the range.

    returns

    A value from that range, inclusive of the ends.

  38. def choosePosLong(from: PosLong, to: PosLong): (PosLong, Randomizer)

    Given a range of positive Longs, chooses one of them randomly.

    Given a range of positive Longs, chooses one of them randomly.

    Note that, while the from parameter is usually smaller than to, that is not required; the function will cope appropriately if they are in reverse order.

    The choice is inclusive: either the from or to values may be returned.

    from

    One end of the range to select from.

    to

    The other end of the range.

    returns

    A value from that range, inclusive of the ends.

  39. def choosePosZDouble(from: PosZDouble, to: PosZDouble): (PosZDouble, Randomizer)

    Given a range of positive Doubles (maybe including zero), chooses one of them randomly.

    Given a range of positive Doubles (maybe including zero), chooses one of them randomly.

    Note that, while the from parameter is usually smaller than to, that is not required; the function will cope appropriately if they are in reverse order.

    The choice is inclusive: either the from or to values may be returned.

    from

    One end of the range to select from.

    to

    The other end of the range.

    returns

    A value from that range, inclusive of the ends.

  40. def choosePosZFiniteDouble(from: PosZFiniteDouble, to: PosZFiniteDouble): (PosZFiniteDouble, Randomizer)

    Given a range of positive, finite Doubles (maybe including zero), chooses one of them randomly.

    Given a range of positive, finite Doubles (maybe including zero), chooses one of them randomly.

    Note that, while the from parameter is usually smaller than to, that is not required; the function will cope appropriately if they are in reverse order.

    The choice is inclusive: either the from or to values may be returned.

    from

    One end of the range to select from.

    to

    The other end of the range.

    returns

    A value from that range, inclusive of the ends.

  41. def choosePosZFiniteFloat(from: PosZFiniteFloat, to: PosZFiniteFloat): (PosZFiniteFloat, Randomizer)

    Given a range of positive, finite Floats (maybe including zero), chooses one of them randomly.

    Given a range of positive, finite Floats (maybe including zero), chooses one of them randomly.

    Note that, while the from parameter is usually smaller than to, that is not required; the function will cope appropriately if they are in reverse order.

    The choice is inclusive: either the from or to values may be returned.

    from

    One end of the range to select from.

    to

    The other end of the range.

    returns

    A value from that range, inclusive of the ends.

  42. def choosePosZFloat(from: PosZFloat, to: PosZFloat): (PosZFloat, Randomizer)

    Given a range of positive Floats (maybe including zero), chooses one of them randomly.

    Given a range of positive Floats (maybe including zero), chooses one of them randomly.

    Note that, while the from parameter is usually smaller than to, that is not required; the function will cope appropriately if they are in reverse order.

    The choice is inclusive: either the from or to values may be returned.

    from

    One end of the range to select from.

    to

    The other end of the range.

    returns

    A value from that range, inclusive of the ends.

  43. def choosePosZInt(from: PosZInt, to: PosZInt): (PosZInt, Randomizer)

    Given a range of positive Ints (maybe including zero), chooses one of them randomly.

    Given a range of positive Ints (maybe including zero), chooses one of them randomly.

    Note that, while the from parameter is usually smaller than to, that is not required; the function will cope appropriately if they are in reverse order.

    The choice is inclusive: either the from or to values may be returned.

    from

    One end of the range to select from.

    to

    The other end of the range.

    returns

    A value from that range, inclusive of the ends.

  44. def choosePosZLong(from: PosZLong, to: PosZLong): (PosZLong, Randomizer)

    Given a range of positive Longs (maybe including zero), chooses one of them randomly.

    Given a range of positive Longs (maybe including zero), chooses one of them randomly.

    Note that, while the from parameter is usually smaller than to, that is not required; the function will cope appropriately if they are in reverse order.

    The choice is inclusive: either the from or to values may be returned.

    from

    One end of the range to select from.

    to

    The other end of the range.

    returns

    A value from that range, inclusive of the ends.

  45. def chooseShort(from: Short, to: Short): (Short, Randomizer)

    Given a range of Shorts, chooses one of them randomly.

    Given a range of Shorts, chooses one of them randomly.

    Note that, while the from parameter is usually smaller than to, that is not required; the function will cope appropriately if they are in reverse order.

    The choice is inclusive: either the from or to values may be returned.

    from

    One end of the range to select from.

    to

    The other end of the range.

    returns

    A value from that range, inclusive of the ends.

  46. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  47. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  48. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  49. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  50. def finiteFloatBetweenAlgorithm(between0And1: Float, min: Float, max: Float): Float

    Given the endpoints of a finite-Float range, and a scaling factor, this computes the number that far across the range.

    Given the endpoints of a finite-Float range, and a scaling factor, this computes the number that far across the range.

    This deals with edge cases that can result in infinities in the math.

    between0And1

    A scaling factor between 0 and 1.

    min

    The lower end of the range.

    max

    The upper end of the range.

    returns

    The Float that is the scaling factor distance across that range.

  51. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  52. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  53. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  54. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  55. def next(bits: Int): (Int, Randomizer)

    Get a certain number of random bits.

    Get a certain number of random bits.

    You don't usually call this directly. Instead, call more-specific functions such as nextInt, which calls this for the correct number of bits and then casts that to the desired type.

    bits

    The number of random bits you need.

    returns

    The random bits, and the next Randomizer to user.

  56. def nextBit: (Int, Randomizer)

    Get a 1 or a 0.

    Get a 1 or a 0.

    returns

    a 1 or 0 as an Int.

  57. def nextByte: (Byte, Randomizer)

    Get a random 8-bit Byte.

    Get a random 8-bit Byte.

    returns

    A random Byte, and the next Randomizer to use.

  58. def nextChar: (Char, Randomizer)

    Get a random 16-bit Char.

    Get a random 16-bit Char.

    Note: this intentionally avoids invalid Unicode chars between 0xD800 and 0xDFFF; when one of those is generated, this instead returns a Char between 0x0000 and 0x00FF. So this function slightly favors that first code block. (Which is the most common one in practice, anyway.)

    returns

    A random Char, and the next Randomizer to use.

  59. def nextDouble: (Double, Randomizer)

    Get a random Double.

    Get a random Double.

    This will randomize the sign, exponent and mantissa, so it can return any possible Double.

    returns

    A random Double, and the next Randomizer to use.

  60. def nextDoubleBetween0And1: (Double, Randomizer)

    Get a random Double between 0 and 1.

    Get a random Double between 0 and 1.

    When working with Double, you often want a value between 0 and 1 -- this sort of proportion is a common use case for Double. This function makes it easy to grab one.

    returns

    A random Double in that range, and the next Randomizer to use.

  61. def nextFiniteDouble: (FiniteDouble, Randomizer)

    Get a random non-infinite Double.

    Get a random non-infinite Double.

    This can return either a positive or negative value, or zero, but guards against returning either Double.PositiveInfinity, Double.NegativeInfinity, or Double.NaN.

    returns

    A random finite Double, and the next Randomizer to use.

  62. def nextFiniteFloat: (FiniteFloat, Randomizer)

    Get a random non-infinite Float.

    Get a random non-infinite Float.

    This can return either a positive or negative value, or zero, but guards against returning either Float.PositiveInfinity, Float.NegativeInfinity, or Float.NaN.

    returns

    A random finite Float, and the next Randomizer to use.

  63. def nextFloat: (Float, Randomizer)

    Get a random Float.

    Get a random Float.

    This will randomize the sign, exponent and mantissa, so it can return any possible Float.

    returns

    A random Float, and the next Randomizer to use.

  64. def nextFloatBetween0And1: (Float, Randomizer)

    Get a random Float between 0 and 1.

    Get a random Float between 0 and 1.

    When working with Floats, you often want a value between 0 and 1 -- this sort of proportion is one of the more common use cases for Floats. This function makes it easy to grab one.

    returns

    A random Float in that range, and the next Randomizer to use.

  65. def nextInt: (Int, Randomizer)

    Get a random 32-bit Int.

    Get a random 32-bit Int.

    returns

    A random Int, and the next Randomizer to use.

  66. def nextList[T](length: PosZInt)(implicit genOfT: Generator[T]): (List[T], Randomizer)

    Get a random list of elements of type T.

    Get a random list of elements of type T.

    This function requires an implicit parameter that says how to generate values of T, as well as the number of them to generate. (Which may be zero.)

    T

    The type to generate.

    length

    How many values to generate for the List.

    genOfT

    A Generator, that provides values of type T.

    returns

    A List of values of the desired type.

  67. def nextLong: (Long, Randomizer)

    Get a random 64-bit Long.

    Get a random 64-bit Long.

    returns

    A random Long, and the next Randomizer to use.

  68. def nextNegDouble: (NegDouble, Randomizer)

    Get a random Double less than zero.

    Get a random Double less than zero.

    Note: it is possible (although rare) for this to return Double.NegativeInfinity. If you want to avoid that, use nextNegFiniteDouble instead.

    returns

    A random negative Double, and the next Randomizer to use.

  69. def nextNegFiniteDouble: (NegFiniteDouble, Randomizer)

    Get a random Double less than zero.

    Get a random Double less than zero.

    This guards against returning Double.NegativeInfinity, so you can have confidence that the returned number is real and finite.

    returns

    A random negative Double, and the next Randomizer to use.

  70. def nextNegFiniteFloat: (NegFiniteFloat, Randomizer)

    Get a random Float less than zero.

    Get a random Float less than zero.

    This guards against returning Float.NegativeInfinity, so you can have confidence that the returned number is real and finite.

    returns

    A random negative Float, and the next Randomizer to use.

  71. def nextNegFloat: (NegFloat, Randomizer)

    Get a random Float less than zero.

    Get a random Float less than zero.

    Note: it is possible (although rare) for this to return Float.NegativeInfinity. If you want to avoid that, use nextNegFiniteFloat instead.

    returns

    A random negative Float, and the next Randomizer to use.

  72. def nextNegInt: (NegInt, Randomizer)

    Get a random Int less than zero.

    Get a random Int less than zero.

    returns

    A random negative Int, and the next Randomizer to use.

  73. def nextNegLong: (NegLong, Randomizer)

    Get a random Long less than zero.

    Get a random Long less than zero.

    returns

    A random negative Long, and the next Randomizer to use.

  74. def nextNegZDouble: (NegZDouble, Randomizer)

    Get a random Double less than or equal to zero.

    Get a random Double less than or equal to zero.

    Note: it is possible (although rare) for this to return Double.NegativeInfinity. If you want to avoid that, use nextNegZFiniteDouble instead.

    returns

    A random negative-or-zero Double, and the next Randomizer to use.

  75. def nextNegZFiniteDouble: (NegZFiniteDouble, Randomizer)

    Get a random Double less than or equal to zero.

    Get a random Double less than or equal to zero.

    This guards against Double.NegativeInfinity, so it will always return a non-infinite value.

    returns

    A random negative-or-zero Double, and the next Randomizer to use.

  76. def nextNegZFiniteFloat: (NegZFiniteFloat, Randomizer)

    Get a random Float less than or equal to zero.

    Get a random Float less than or equal to zero.

    This guards against Float.NegativeInfinity, so it will always return a non-infinite value.

    returns

    A random negative-or-zero Float, and the next Randomizer to use.

  77. def nextNegZFloat: (NegZFloat, Randomizer)

    Get a random Float less than or equal to zero.

    Get a random Float less than or equal to zero.

    Note: it is possible (although rare) for this to return Float.NegativeInfinity. If you want to avoid that, use nextNegZFiniteFloat instead.

    returns

    A random negative-or-zero Float, and the next Randomizer to use.

  78. def nextNegZInt: (NegZInt, Randomizer)

    Get a random Int less than or equal to zero.

    Get a random Int less than or equal to zero.

    returns

    A random negative-or-zero Int, and the next Randomizer to use.

  79. def nextNegZLong: (NegZLong, Randomizer)

    Get a random Long less than or equal to zero.

    Get a random Long less than or equal to zero.

    returns

    A random negative-or-zero Long, and the next Randomizer to use.

  80. def nextNonZeroDouble: (NonZeroDouble, Randomizer)

    Get a random non-zero Double.

    Get a random non-zero Double.

    This can return any Double except zero.

    Note that this can return infinite values; if you want to avoid that, use nextNonZeroFiniteDouble instead.

    returns

    A random non-zero Double, and the next Randomizer to use.

  81. def nextNonZeroFiniteDouble: (NonZeroFiniteDouble, Randomizer)

    Get a random non-zero Double.

    Get a random non-zero Double.

    This can return any Double except zero, Double.PositiveInfinity, or Double.NegativeInfinity.

    returns

    A random non-zero Double, and the next Randomizer to use.

  82. def nextNonZeroFiniteFloat: (NonZeroFiniteFloat, Randomizer)

    Get a random non-zero Float.

    Get a random non-zero Float.

    This can return any Float except zero, Float.PositiveInfinity, or Float.NegativeInfinity.

    returns

    A random non-zero Float, and the next Randomizer to use.

  83. def nextNonZeroFloat: (NonZeroFloat, Randomizer)

    Get a random non-zero Float.

    Get a random non-zero Float.

    This can return any Float except zero.

    Note that this can return infinite values; if you want to avoid that, use nextNonZeroFiniteFloat instead.

    returns

    A random non-zero Float, and the next Randomizer to use.

  84. def nextNonZeroInt: (NonZeroInt, Randomizer)

    Get a random non-zero Int.

    Get a random non-zero Int.

    This can return any Int except zero.

    returns

    A random non-zero Int, and the next Randomizer to use.

  85. def nextNonZeroLong: (NonZeroLong, Randomizer)

    Get a random non-zero Long.

    Get a random non-zero Long.

    This can return any Long except zero.

    returns

    A random non-zero Long, and the next Randomizer to use.

  86. def nextPosDouble: (PosDouble, Randomizer)

    Get a random Double greater than zero.

    Get a random Double greater than zero.

    Note: it is possible (although rare) for this to return Double.PositiveInfinity. If you want to avoid that, use nextPosFiniteDouble instead.

    returns

    A random positive Double, and the next Randomizer to use.

  87. def nextPosFiniteDouble: (PosFiniteDouble, Randomizer)

    Get a random Double greater than zero.

    Get a random Double greater than zero.

    This guards against returning Double.PositiveInfinity, so you can have confidence that the returned number is real and finite.

    returns

    A random positive Double, and the next Randomizer to use.

  88. def nextPosFiniteFloat: (PosFiniteFloat, Randomizer)

    Get a random, finite Float greater than zero.

    Get a random, finite Float greater than zero.

    This methods guards against returning Float.PositiveInfinity -- you will always receive a real value.

    returns

    A random positive Float, and the next Randomizer to use.

  89. def nextPosFloat: (PosFloat, Randomizer)

    Get a random Float greater than zero.

    Get a random Float greater than zero.

    Note: it is possible (although rare) for this to return Float.PositiveInfinity. If you want to avoid that, use nextPosFiniteFloat instead.

    returns

    A random positive Float, and the next Randomizer to use.

  90. def nextPosInt: (PosInt, Randomizer)

    Get a random Integer greater than zero.

    Get a random Integer greater than zero.

    Note: if the underlying algorithm tries to generate 0, this generates 1, so it is very slightly biased towards returning 1.

    returns

    A random positive Integer, and the next Randomizer to use.

  91. def nextPosLong: (PosLong, Randomizer)

    Get a random Long greater than zero.

    Get a random Long greater than zero.

    returns

    A random positive Long, and the next Randomizer to use.

  92. def nextPosZDouble: (PosZDouble, Randomizer)

    Get a random Double greater than or equal to zero.

    Get a random Double greater than or equal to zero.

    Note: it is possible (although rare) for this to return Double.NegativeInfinity. If you want to avoid that, use nextPosZFiniteDouble instead.

    returns

    A random positive Double, and the next Randomizer to use.

  93. def nextPosZFiniteDouble: (PosZFiniteDouble, Randomizer)

    Get a random Double greater than or equal to zero.

    Get a random Double greater than or equal to zero.

    This guards against returning Double.NegativeInfinity.

    returns

    A random negative Double, and the next Randomizer to use.

  94. def nextPosZFiniteFloat: (PosZFiniteFloat, Randomizer)

    Get a random Float greater than or equal to zero.

    Get a random Float greater than or equal to zero.

    This guards against returning Float.PositiveInfinity.

    returns

    A random positive Float, and the next Randomizer to use.

  95. def nextPosZFloat: (PosZFloat, Randomizer)

    Get a random Float greater than or equal to zero.

    Get a random Float greater than or equal to zero.

    Note: it is possible (although rare) for this to return Float.PositiveInfinity. If you want to avoid that, use nextPosZFiniteFloat instead.

    returns

    A random positive Float, and the next Randomizer to use.

  96. def nextPosZInt: (PosZInt, Randomizer)

    Get a random Integer greater than or equal to zero.

    Get a random Integer greater than or equal to zero.

    returns

    A random positive Integer (or zero), and the next Randomizer to use.

  97. def nextPosZLong: (PosZLong, Randomizer)

    Get a random Long greater than or equal to zero.

    Get a random Long greater than or equal to zero.

    returns

    A random positive Long (or zero), and the next Randomizer to use.

  98. def nextRandomizer: Randomizer

    Computes the next Randomizer to use.

    Computes the next Randomizer to use.

    Since Randomizer is immutable (and would thus return the same value over and over), you don't usually use the same instance more than once. Instead, you should fetch the next one, and use that for the next operation.

    You usually don't need to call this directly; instead, the next Randomizer is returned from each operation, along with the random value.

    returns

    The next Randomizer, ready to use.

  99. def nextShort: (Short, Randomizer)

    Get a random 16-bit Short.

    Get a random 16-bit Short.

    returns

    A random Short, and the next Randomizer to use.

  100. def nextString(length: PosZInt): (String, Randomizer)

    Get a random String.

    Get a random String.

    This takes a desired length, and generates a String of that length. Do not expect this String to make any sense -- it is literally just a string of random Unicode characters, and will typically contain little or no conventional ASCII.

    length

    The number of characters to include in the String.

    returns

    A highly-random String of the specified length, and the next Randomizer to use.

  101. final def notify(): Unit

    Definition Classes
    AnyRef
  102. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  103. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  104. def toString(): String

    Definition Classes
    AnyRef → Any
  105. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  106. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  107. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from AnyRef

Inherited from Any

Ungrouped