XU XUv0.8.8
中文

API

#math/rand

import: #math/rand

counts: 1 fns, 7 methods, 1 types, 0 consts, 0 ifaces

Source instances. No global source. xorshift64*; intn uses rejection sampling.

struct Source

XuAPI
pub struct Source {
    pub state int
}

Purpose

Public struct `Source`.

Parameters

state int
field (int)

new_source

XuAPI
pub fn new_source(seed int) Source

Purpose

Construct source.

Parameters

seed int
random seed (int)

Returns

Source — a value of this type

(&mut Source) seed

XuAPI
pub fn (s &mut Source) seed(seed int)

Purpose

Call `seed` on `&mut Source`.

Parameters

s &mut Source
receiver &mut Source (exclusive borrow)
seed int
random seed (int)

(&mut Source) int63

XuAPI
pub fn (s &mut Source) int63() int

Purpose

Call `int63` on `&mut Source`.

Parameters

s &mut Source
receiver &mut Source (exclusive borrow)

Returns

int — a value of this type

(&mut Source) intn

XuAPI
pub fn (s &mut Source) intn(n int) int

Purpose

Call `intn` on `&mut Source`.

Parameters

s &mut Source
receiver &mut Source (exclusive borrow)
n int
count, length, or limit (int)

Returns

int — a value of this type

(&mut Source) float64

XuAPI
pub fn (s &mut Source) float64() f64

Purpose

Call `float64` on `&mut Source`.

Parameters

s &mut Source
receiver &mut Source (exclusive borrow)

Returns

f64 — a value of this type

(&mut Source) int31

XuAPI
pub fn (s &mut Source) int31() int

Purpose

Call `int31` on `&mut Source`.

Parameters

s &mut Source
receiver &mut Source (exclusive borrow)

Returns

int — a value of this type

(&mut Source) perm

XuAPI
pub fn (s &mut Source) perm(n int) []int

Purpose

Method on `&mut Source`: permutation.

Parameters

s &mut Source
receiver &mut Source (exclusive borrow)
n int
count, length, or limit (int)

Returns

[]int — slice result

(&mut Source) shuffle

XuAPI
pub fn (s &mut Source) shuffle(a &mut []int)

Purpose

Method on `&mut Source`: shuffle.

Parameters

s &mut Source
receiver &mut Source (exclusive borrow)
a &mut []int
slice to operate on (exclusive borrow; type &mut []int)