pub mod aes_ctr;
pub mod bad;
pub mod block_ctr;
pub mod c_stdlib;
pub mod chacha20_rng;
pub mod crypto_cprng;
pub mod dual_ec;
pub mod hash_drbg;
pub mod hmac_drbg;
pub mod lcg;
pub mod mt19937;
pub mod os;
pub mod pcg;
pub mod sfc;
pub mod spongebob;
pub mod squidward;
pub mod stream_rng;
pub mod wyrand;
pub mod xorshift;
pub mod xoshiro;
pub use aes_ctr::AesCtr;
pub use bad::{ConstantRng, CounterRng};
pub use block_ctr::BlockCtrRng;
pub use c_stdlib::{
BsdRandCompat, BsdRandom, CRand, LinuxLibcRandom, Rand48, SystemVRand, WindowsDotNetRandom,
WindowsMsvcRand, WindowsVb6Rnd,
};
pub use chacha20_rng::ChaCha20Rng;
pub use crypto_cprng::CryptoCtrDrbg;
pub use dual_ec::DualEcDrbg;
pub use hash_drbg::HashDrbg;
pub use hmac_drbg::HmacDrbg;
pub use lcg::{Lcg32, LcgVariant};
pub use mt19937::Mt19937;
pub use os::OsRng;
pub use pcg::{Pcg32, Pcg64};
pub use sfc::{Jsf64, Sfc64};
pub use spongebob::SpongeBob;
pub use squidward::Squidward;
pub use stream_rng::StreamRng;
pub use wyrand::WyRand;
pub use xorshift::{Xorshift32, Xorshift64};
pub use xoshiro::{Xoroshiro128, Xoshiro256};
pub trait Rng {
fn next_u32(&mut self) -> u32;
fn next_u64(&mut self) -> u64 {
((self.next_u32() as u64) << 32) | (self.next_u32() as u64)
}
fn next_f64(&mut self) -> f64 {
self.next_u32() as f64 * (1.0 / 4_294_967_296.0)
}
fn collect_bits(&mut self, n: usize) -> Vec<u8> {
let mut bits = Vec::with_capacity(n);
let mut remaining = n;
while remaining > 0 {
let word = self.next_u32();
let take = remaining.min(32);
for i in 0..take {
bits.push(((word >> i) & 1) as u8);
}
remaining -= take;
}
bits
}
fn collect_u32s(&mut self, n: usize) -> Vec<u32> {
(0..n).map(|_| self.next_u32()).collect()
}
fn collect_f64s(&mut self, n: usize) -> Vec<f64> {
(0..n).map(|_| self.next_f64()).collect()
}
}