class · System

Random

public class System.Random : System.Any

Pseudo-random numbers. new Random(seed) gives the same numbers for the same seed; new Random() and Random.Shared are seeded from the clock (and a counter, so two made at once differ). Not for secrets.

Tipo
class
Espacio de nombres
System
Ensamblado
System.Core
Acceso
public
Archivo fuente
Random.ant

Herencia

Clases base
Any Random

Constructores

constructor Random()
#

Seeded from the clock.

constructor Random(seed: i32)
#

The same numbers for the same seed.

Propiedades

static property Shared: System.Random
#

static read-only

One shared generator (seeded from the clock).

Métodos

method NextUInt64() -> u64
#

64 random bits.

method Next() -> i32
#

From 0 up to (not including) Int32.MaxValue.

method Next(max: i32) -> i32
#

From 0 up to (not including) max (0 when max is 0).

method Next(min: i32, max: i32) -> i32
#

From min up to (not including) max (min when they are equal).

method NextInt64() -> i64
#

From 0 up to (not including) Int64.MaxValue.

method NextInt64(max: i64) -> i64
#

From 0 up to (not including) max.

method NextInt64(min: i64, max: i64) -> i64
#

From min up to (not including) max.

method NextDouble() -> f64
#

From 0 up to (not including) 1, in steps of 2^-53.

method NextSingle() -> f32
#

From 0 up to (not including) 1, in steps of 2^-24.

method NextBytes(buffer: u8[]) -> void
#

Fills buffer with random bytes.

method Shuffle<T>(items: T[]) -> void
#

Puts the elements in a random order (Fisher–Yates: every order as likely).

Miembros privados e internos (10)

field s0: u64
#

private

field s1: u64
#

private

field s2: u64
#

private

field s3: u64
#

private

static field made: u64
#

private static

static field shared: System.Random?
#

private static

method Seed(seed: u64) -> void
#

private

SplitMix64: spreads a seed over the four words of the state (never all zero).

static method Mix(z: u64) -> u64
#

private static

method Below(bound: u32) -> u32
#

private

Values below bound (> 0), all as likely: the high half of a 64-bit product (Lemire), retried in the rare band that would favour some values.

method Below64(bound: u64) -> u64
#

private

Values below bound (> 0), all as likely: masked draws, retried when past the bound.

Miembros heredados (5)

Código fuente

Random en Larva HIR, descompilado a partir de su Larva HIR.

System.Random.hir
// Pseudo-random numbers. `new Random(seed)` gives the same numbers for the same seed; `new Random()` and
// `Random.Shared` are seeded from the clock (and a counter, so two made at once differ). Not for secrets.
public class System.Random : System.Any
{
    field s0: u64
    field s1: u64
    field s2: u64
    field s3: u64
    static field made: u64
    static field shared: System.Random?
    // SplitMix64: spreads a seed over the four words of the state (never all zero).
    method Seed(seed: u64) -> void
    static method Mix(z: u64) -> u64
    // Values below `bound` (> 0), all as likely: the high half of a 64-bit product (Lemire), retried in the rare
    // band that would favour some values.
    method Below(bound: u32) -> u32
    // Values below `bound` (> 0), all as likely: masked draws, retried when past the bound.
    method Below64(bound: u64) -> u64
    // Seeded from the clock.
    constructor Random()
    // The same numbers for the same seed.
    constructor Random(seed: i32)
    // 64 random bits.
    method NextUInt64() -> u64
    // From 0 up to (not including) Int32.MaxValue.
    method Next() -> i32
    // From 0 up to (not including) `max` (0 when max is 0).
    method Next(max: i32) -> i32
    // From `min` up to (not including) `max` (min when they are equal).
    method Next(min: i32, max: i32) -> i32
    // From 0 up to (not including) Int64.MaxValue.
    method NextInt64() -> i64
    // From 0 up to (not including) `max`.
    method NextInt64(max: i64) -> i64
    // From `min` up to (not including) `max`.
    method NextInt64(min: i64, max: i64) -> i64
    // From 0 up to (not including) 1, in steps of 2^-53.
    method NextDouble() -> f64
    // From 0 up to (not including) 1, in steps of 2^-24.
    method NextSingle() -> f32
    // Fills `buffer` with random bytes.
    method NextBytes(buffer: u8[]) -> void
    // Puts the elements in a random order (Fisher–Yates: every order as likely).
    method Shuffle<T>(items: T[]) -> void
    // One shared generator (seeded from the clock).
    static property Shared: System.Random
}
Esc