Zig 0.17.0-dev (Split by item) This is an example of documentation generated by
ZigDoc , an alternative to Zig's built-in
Auto Doc feature. See also
examples in other modes/formats . The project being documented here (as the example) is the Zig standard library.
std › treap › Treap › Prng › random Private Function random Doc Source Private Function std.treap.Treap.Prng.random
fn random (self : *Prng , seed : usize ) usize Params File treap.zig: 25
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45 fn random (self : *Prng , seed : usize ) usize {
// Lazily seed the prng state
if (self .xorshift == 0 ) {
self .xorshift = seed ;
}
// Since we're using usize, decide the shifts by the integer's bit width.
const shifts = switch (@bitSizeOf (usize )) {
64 => .{ 13 , 7 , 17 },
32 => .{ 13 , 17 , 5 },
16 => .{ 7 , 9 , 8 },
else => @compileError ("platform not supported" ),
};
self .xorshift ^= self .xorshift >> shifts [0 ];
self .xorshift ^= self .xorshift << shifts [1 ];
self .xorshift ^= self .xorshift >> shifts [2 ];
assert (self .xorshift != 0 );
return self .xorshift ;
}