open class RandomState

A pseudorandom state.

  • The global pseudorandom state.

    Declaration

    public static let global: RandomState
  • Creates a pseudorandom state by copying from another pseudorandom state.

    Declaration

    public init(_ other: RandomState)

    Parameters

    other

    The pseudorandom state to copy from.

  • Creates a pseudorandom state with the given seed.

    Declaration

    public convenience init(seed: UInt32)

    Parameters

    seed

    A number used to initialize the pseudorandom state.

  • Seed the pseudorandom state.

    Note

    Users should not re-seed the global state unless there is a compelling reason to do so.

    Declaration

    open func seed(with seed: UInt32)

    Parameters

    seed

    The seed to be used to initialize the internal psuedorandom state.

  • Returns the next pseudorandom number and updates the internal state.

    Declaration

    open func generate() -> Int32

    Return Value

    The next pseudorandom number.

  • Returns an array containing the next specified count of pseudorandom numbers and updates the internal state.

    Declaration

    open func generate(_ count: Int) -> [Int32]

    Parameters

    count

    The number of pseudorandom numbers to generate.

    Return Value

    An array containing the next pseudorandom numbers.