aboutsummaryrefslogtreecommitdiff
path: root/std
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2016-01-24 19:27:12 -0700
committerAndrew Kelley <superjoe30@gmail.com>2016-01-24 19:27:12 -0700
commitf5cc7f65a3764e90b0daaa0388f683589ee105e0 (patch)
treee77013dcc1462292eef2e21fdb9b27dc3d752696 /std
parent419652ee8ff709deae988603ecca2c335599d969 (diff)
downloadzig-f5cc7f65a3764e90b0daaa0388f683589ee105e0.tar.gz
zig-f5cc7f65a3764e90b0daaa0388f683589ee105e0.zip
fix parameter access of sret functions
Diffstat (limited to 'std')
-rw-r--r--std/rand.zig28
1 files changed, 14 insertions, 14 deletions
diff --git a/std/rand.zig b/std/rand.zig
index 63380e2dc5..2940d35349 100644
--- a/std/rand.zig
+++ b/std/rand.zig
@@ -6,20 +6,6 @@ pub struct Rand {
array: [ARRAY_SIZE]u32,
index: isize,
- /// Initialize random state with the given seed.
- pub fn init(r: &Rand, seed: u32) => {
- r.index = 0;
- r.array[0] = seed;
- var i : isize = 1;
- var prev_value: u64 = seed;
- while (i < ARRAY_SIZE) {
- r.array[i] = u32((prev_value ^ (prev_value << 30)) * 0x6c078965 + u32(i));
- prev_value = r.array[i];
- i += 1;
- }
- }
-
-
/// Get 32 bits of randomness.
pub fn get_u32(r: &Rand) u32 => {
if (r.index == 0) {
@@ -91,3 +77,17 @@ pub struct Rand {
}
}
+/// Initialize random state with the given seed.
+pub fn rand_new(seed: u32) Rand => {
+ var r: Rand;
+ r.index = 0;
+ r.array[0] = seed;
+ var i : isize = 1;
+ var prev_value: u64 = seed;
+ while (i < ARRAY_SIZE) {
+ r.array[i] = u32((prev_value ^ (prev_value << 30)) * 0x6c078965 + u32(i));
+ prev_value = r.array[i];
+ i += 1;
+ }
+ return r;
+}