Class/Object

org.scalatest.prop

Randomizer

Related Docs: object Randomizer | package prop

Permalink

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
Visibility
  1. Public
  2. All

Instance Constructors

  1. new Randomizer(seed: Long)

    Permalink

Value Members

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

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

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

    Permalink
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0

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

    Permalink

    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.

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

    Permalink

    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.

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

    Permalink

    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.

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

    Permalink

    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.

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

    Permalink

    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.

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

    Permalink

    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.

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

    Permalink

    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.

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

    Permalink

    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.

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

    Permalink

    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.

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

    Permalink

    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.

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

    Permalink

    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.

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

    Permalink

    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.

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

    Permalink

    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.

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

    Permalink

    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.

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

    Permalink

    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.

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

    Permalink

    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.

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

    Permalink

    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.

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

    Permalink

    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.

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

    Permalink

    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.

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

    Permalink

    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.

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

    Permalink

    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.

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

    Permalink

    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.

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

    Permalink

    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.

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

    Permalink

    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.

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

    Permalink

    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.

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

    Permalink

    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.

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

    Permalink

    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.

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

    Permalink

    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.

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

    Permalink

    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.

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

    Permalink

    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.

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

    Permalink

    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.

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

    Permalink

    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.

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

    Permalink

    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.

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

    Permalink

    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.

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

    Permalink

    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.

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

    Permalink

    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.

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

    Permalink

    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.

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

    Permalink

    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.

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

    Permalink

    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.

  44. def clone(): AnyRef

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

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

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

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

    Permalink

    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.

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

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

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

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

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

    Permalink

    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.

  54. def nextBit: (Int, Randomizer)

    Permalink

    Get a 1 or a 0.

    Get a 1 or a 0.

    returns

    a 1 or 0 as an Int.

  55. def nextByte: (Byte, Randomizer)

    Permalink

    Get a random 8-bit Byte.

    Get a random 8-bit Byte.

    returns

    A random Byte, and the next Randomizer to use.

  56. def nextChar: (Char, Randomizer)

    Permalink

    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.

  57. def nextDouble: (Double, Randomizer)

    Permalink

    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.

  58. def nextDoubleBetween0And1: (Double, Randomizer)

    Permalink

    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.

  59. def nextFiniteDouble: (FiniteDouble, Randomizer)

    Permalink

    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.

  60. def nextFiniteFloat: (FiniteFloat, Randomizer)

    Permalink

    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.

  61. def nextFloat: (Float, Randomizer)

    Permalink

    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.

  62. def nextFloatBetween0And1: (Float, Randomizer)

    Permalink

    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.

  63. def nextInt: (Int, Randomizer)

    Permalink

    Get a random 32-bit Int.

    Get a random 32-bit Int.

    returns

    A random Int, and the next Randomizer to use.

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

    Permalink

    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.

  65. def nextLong: (Long, Randomizer)

    Permalink

    Get a random 64-bit Long.

    Get a random 64-bit Long.

    returns

    A random Long, and the next Randomizer to use.

  66. def nextNegDouble: (NegDouble, Randomizer)

    Permalink

    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.

  67. def nextNegFiniteDouble: (NegFiniteDouble, Randomizer)

    Permalink

    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.

  68. def nextNegFiniteFloat: (NegFiniteFloat, Randomizer)

    Permalink

    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.

  69. def nextNegFloat: (NegFloat, Randomizer)

    Permalink

    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.

  70. def nextNegInt: (NegInt, Randomizer)

    Permalink

    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.

  71. def nextNegLong: (NegLong, Randomizer)

    Permalink

    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.

  72. def nextNegZDouble: (NegZDouble, Randomizer)

    Permalink

    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.

  73. def nextNegZFiniteDouble: (NegZFiniteDouble, Randomizer)

    Permalink

    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.

  74. def nextNegZFiniteFloat: (NegZFiniteFloat, Randomizer)

    Permalink

    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.

  75. def nextNegZFloat: (NegZFloat, Randomizer)

    Permalink

    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.

  76. def nextNegZInt: (NegZInt, Randomizer)

    Permalink

    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.

  77. def nextNegZLong: (NegZLong, Randomizer)

    Permalink

    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.

  78. def nextNonZeroDouble: (NonZeroDouble, Randomizer)

    Permalink

    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.

  79. def nextNonZeroFiniteDouble: (NonZeroFiniteDouble, Randomizer)

    Permalink

    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.

  80. def nextNonZeroFiniteFloat: (NonZeroFiniteFloat, Randomizer)

    Permalink

    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.

  81. def nextNonZeroFloat: (NonZeroFloat, Randomizer)

    Permalink

    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.

  82. def nextNonZeroInt: (NonZeroInt, Randomizer)

    Permalink

    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.

  83. def nextNonZeroLong: (NonZeroLong, Randomizer)

    Permalink

    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.

  84. def nextPosDouble: (PosDouble, Randomizer)

    Permalink

    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.

  85. def nextPosFiniteDouble: (PosFiniteDouble, Randomizer)

    Permalink

    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.

  86. def nextPosFiniteFloat: (PosFiniteFloat, Randomizer)

    Permalink

    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.

  87. def nextPosFloat: (PosFloat, Randomizer)

    Permalink

    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.

  88. def nextPosInt: (PosInt, Randomizer)

    Permalink

    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.

  89. def nextPosLong: (PosLong, Randomizer)

    Permalink

    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.

  90. def nextPosZDouble: (PosZDouble, Randomizer)

    Permalink

    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.

  91. def nextPosZFiniteDouble: (PosZFiniteDouble, Randomizer)

    Permalink

    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.

  92. def nextPosZFiniteFloat: (PosZFiniteFloat, Randomizer)

    Permalink

    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.

  93. def nextPosZFloat: (PosZFloat, Randomizer)

    Permalink

    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.

  94. def nextPosZInt: (PosZInt, Randomizer)

    Permalink

    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.

  95. def nextPosZLong: (PosZLong, Randomizer)

    Permalink

    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.

  96. def nextRandomizer: Randomizer

    Permalink

    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.

  97. def nextShort: (Short, Randomizer)

    Permalink

    Get a random 16-bit Short.

    Get a random 16-bit Short.

    returns

    A random Short, and the next Randomizer to use.

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

    Permalink

    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.

  99. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  100. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  101. val seed: Long

    Permalink
  102. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  103. def toString(): String

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

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

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

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from AnyRef

Inherited from Any

Ungrouped