XU XUv0.8.8
EN

API

#math/rand

import: #math/rand

counts: 1 函数, 7 方法, 1 类型, 0 常量, 0 方法集

Source 实例。无全局源。xorshift64*,intn 拒绝采样。

struct Source

XuAPI
pub struct Source {
    pub state int
}

用途

公开结构体 `Source`。

参数

state int
字段(int)

new_source

XuAPI
pub fn new_source(seed int) Source

用途

构造 source。

参数

seed int
随机种子(int)

返回

Source — 该类型的值

(&mut Source) seed

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

用途

`&mut Source` 上的方法:种子。

参数

s &mut Source
接收者 &mut Source(可变借用)
seed int
随机种子(int)

(&mut Source) int63

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

用途

在 `&mut Source` 上调用 `int63`。

参数

s &mut Source
接收者 &mut Source(可变借用)

返回

int — 该类型的值

(&mut Source) intn

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

用途

在 `&mut Source` 上调用 `intn`。

参数

s &mut Source
接收者 &mut Source(可变借用)
n int
数量、长度或上限(int)

返回

int — 该类型的值

(&mut Source) float64

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

用途

在 `&mut Source` 上调用 `float64`。

参数

s &mut Source
接收者 &mut Source(可变借用)

返回

f64 — 该类型的值

(&mut Source) int31

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

用途

在 `&mut Source` 上调用 `int31`。

参数

s &mut Source
接收者 &mut Source(可变借用)

返回

int — 该类型的值

(&mut Source) perm

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

用途

`&mut Source` 上的方法:排列。

参数

s &mut Source
接收者 &mut Source(可变借用)
n int
数量、长度或上限(int)

返回

[]int — 切片结果

(&mut Source) shuffle

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

用途

`&mut Source` 上的方法:打乱。

参数

s &mut Source
接收者 &mut Source(可变借用)
a &mut []int
要处理的切片(独占借用;类型 &mut []int)