1mod context_ext;
2mod sampling_algorithms;
3
4use std::any::{Any, TypeId};
5use std::cell::RefCell;
6
7pub use context_ext::ContextRandomExt;
8pub use sampling_algorithms::{
9 count_and_sample_single_l_reservoir, sample_multiple_from_known_length,
10 sample_multiple_l_reservoir, sample_single_excluding, sample_single_excluding_iteration,
11 sample_single_excluding_l_reservoir, sample_single_excluding_rejection,
12 sample_single_from_known_length, sample_single_l_reservoir,
13};
14
15pub use crate::define_rng;
16use crate::rand::SeedableRng;
17use crate::{define_data_plugin, HashMap, HashMapExt};
18
19pub trait RngId: Copy + Clone {
20 type RngType: SeedableRng;
21 fn get_name() -> &'static str;
22}
23
24struct RngHolder {
27 rng: Box<dyn Any>,
28}
29
30struct RngData {
31 base_seed: u64,
32 rng_holders: RefCell<HashMap<TypeId, RngHolder>>,
33}
34
35define_data_plugin!(
41 RngPlugin,
42 RngData,
43 RngData {
44 base_seed: 0,
45 rng_holders: RefCell::new(HashMap::new()),
46 }
47);