Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More improvements to std::rand #9695

Merged
merged 22 commits into from
Oct 9, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
72bf201
std::rand: move the Isaac implementation to its own file.
huonw Sep 21, 2013
a2b5096
std::rand: Add an implementation of ISAAC64.
huonw Sep 21, 2013
39a69d3
std::rand: Add OSRng, ReaderRng wrappers around the OS RNG & generic …
huonw Sep 22, 2013
f39a215
std::rand: add the StdRng wrapper for a blessed RNG.
huonw Sep 26, 2013
0223cf6
std::rand: Add ReseedingRng, which will reseed an RNG after it genera…
huonw Sep 29, 2013
92725ae
std::rand: Add a trait for seeding RNGs: SeedableRng.
huonw Sep 29, 2013
fb97063
std::rand: improve the task_rng code.
huonw Sep 30, 2013
29e3b33
std::rand: make the windows OSRng more correct, remove some C++.
huonw Oct 1, 2013
6f4ec72
std::rand: add & split some tests.
huonw Oct 1, 2013
0b1a0d0
std::rand: move the Rand impls into a separate file for neatness.
huonw Oct 1, 2013
9886979
std::rand: documentation additions & fixes.
huonw Oct 1, 2013
9db32a2
std::rand: adjust the f32 & f64 Rand instances.
huonw Oct 3, 2013
5bb5f76
Convert rt::sched::new_sched_rng to use open/read/close rather than f*.
huonw Oct 8, 2013
71addde
std::rand: remove `seed`.
huonw Oct 8, 2013
a836f13
Documentation & address minor point.
huonw Oct 8, 2013
38732c4
std::rand: Correct the implementation of Rand for f32 & f64.
huonw Oct 8, 2013
649c175
std::rand::reader: describe cfg!(endianness).
huonw Oct 8, 2013
d86de18
std::rand::reseeding: seed the reseeder in the SeedableRng impl.
huonw Oct 8, 2013
618c6af
std::rand::os: use the externfn! macro for the Windows RNG.
huonw Oct 8, 2013
62feded
std::rand: Make Rng.next_u32 non-default, waiting for #7771.
huonw Oct 8, 2013
5442a47
std::rand: remove seed_task_rng and RUST_SEED.
huonw Oct 9, 2013
e678435
std::rand: Minor clean-up of comments & add a missing default method.
huonw Oct 9, 2013
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion mk/rt.mk
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ RUNTIME_CXXS_$(1)_$(2) := \
rt/sync/lock_and_signal.cpp \
rt/sync/rust_thread.cpp \
rt/rust_builtin.cpp \
rt/rust_rng.cpp \
rt/rust_upcall.cpp \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

woohoo!

rt/rust_uv.cpp \
rt/miniz.cpp \
Expand Down
20 changes: 10 additions & 10 deletions src/libextra/bitv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1524,16 +1524,16 @@ mod tests {
}

fn rng() -> rand::IsaacRng {
let seed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0];
rand::IsaacRng::new_seeded(seed)
let seed = &[1, 2, 3, 4, 5, 6, 7, 8, 9, 0];
rand::SeedableRng::from_seed(seed)
}

#[bench]
fn bench_uint_small(b: &mut BenchHarness) {
let mut r = rng();
let mut bitv = 0 as uint;
do b.iter {
bitv |= (1 << ((r.next() as uint) % uint::bits));
bitv |= (1 << ((r.next_u32() as uint) % uint::bits));
}
}

Expand All @@ -1542,7 +1542,7 @@ mod tests {
let mut r = rng();
let mut bitv = SmallBitv::new(uint::bits);
do b.iter {
bitv.set((r.next() as uint) % uint::bits, true);
bitv.set((r.next_u32() as uint) % uint::bits, true);
}
}

Expand All @@ -1551,7 +1551,7 @@ mod tests {
let mut r = rng();
let mut bitv = BigBitv::new(~[0]);
do b.iter {
bitv.set((r.next() as uint) % uint::bits, true);
bitv.set((r.next_u32() as uint) % uint::bits, true);
}
}

Expand All @@ -1562,7 +1562,7 @@ mod tests {
storage.grow(BENCH_BITS / uint::bits, &0u);
let mut bitv = BigBitv::new(storage);
do b.iter {
bitv.set((r.next() as uint) % BENCH_BITS, true);
bitv.set((r.next_u32() as uint) % BENCH_BITS, true);
}
}

Expand All @@ -1571,7 +1571,7 @@ mod tests {
let mut r = rng();
let mut bitv = Bitv::new(BENCH_BITS, false);
do b.iter {
bitv.set((r.next() as uint) % BENCH_BITS, true);
bitv.set((r.next_u32() as uint) % BENCH_BITS, true);
}
}

Expand All @@ -1580,7 +1580,7 @@ mod tests {
let mut r = rng();
let mut bitv = Bitv::new(uint::bits, false);
do b.iter {
bitv.set((r.next() as uint) % uint::bits, true);
bitv.set((r.next_u32() as uint) % uint::bits, true);
}
}

Expand All @@ -1589,7 +1589,7 @@ mod tests {
let mut r = rng();
let mut bitv = BitvSet::new();
do b.iter {
bitv.insert((r.next() as uint) % uint::bits);
bitv.insert((r.next_u32() as uint) % uint::bits);
}
}

Expand All @@ -1598,7 +1598,7 @@ mod tests {
let mut r = rng();
let mut bitv = BitvSet::new();
do b.iter {
bitv.insert((r.next() as uint) % BENCH_BITS);
bitv.insert((r.next_u32() as uint) % BENCH_BITS);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/libextra/treemap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1013,7 +1013,7 @@ mod test_treemap {
check_equal(ctrl, &map);
assert!(map.find(&5).is_none());

let mut rng = rand::IsaacRng::new_seeded(&[42]);
let mut rng: rand::IsaacRng = rand::SeedableRng::from_seed(&[42]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:(, I'll allow it though


do 3.times {
do 90.times {
Expand Down
Loading