random_wheel/
lib.rs

1//! A Little implementation of the random-wheel principle, `RandomWheel<T>`.
2//! https://wikipedia.org/wiki/Fitness_proportionate_selection
3//!
4//! ![Fitness proportionate selection](https://upload.wikimedia.org/wikipedia/commons/2/2a/Fitness_proportionate_selection_example.png)
5//!
6//! # Usage
7//!
8//! You can get this package on the
9//! [crates.io/random-wheel](https://crates.io/crates/random-wheel) page.
10//!
11//! # Examples
12//!
13//! You can explicitly create a `RandomWheel<T>` with `new()`:
14//!
15//! ```
16//! use random_wheel::RandomWheel;
17//!
18//! let rw: RandomWheel<u8> = RandomWheel::new();
19//! ```
20//!
21//! You can `push` values onto the random-wheel (which will grow the wheel as needed):
22//!
23//! Popping values works in much the same way:
24//!
25//! ```
26//! use random_wheel::RandomWheel;
27//!
28//! let mut rw = RandomWheel::new();
29//!
30//! rw.push(5., 'a');
31//! rw.push(1., 'b');
32//!
33//! // you have 5 chances out of 6 to pop 'a'
34//! let a_or_b = rw.pop();
35//! ```
36
37mod random_wheel;
38pub use random_wheel::RandomWheel;