pub(crate) fn choose_weighted(rng: &mut RngType, weights: &[u64]) -> usize {
    let max = weights.last().unwrap();
    let n = rng.gen_range(0..*max);
    match weights.binary_search(&n) {
        Ok(idx) => idx + 1,
        Err(idx) => idx,
    }
}
/// Return chosen index based on `weights`.
///
/// Weight is accumulated value. For example, [10, 35, 50] means each item has
/// 10%, 25%, 15% to be chosen.
Return chosen index based on `weights`.
Weight is accumulated value.
Return chosen index based on ` weights ` . Weight is accumulated value .
pub(crate) fn choose_weighted(rng: &mut RngType, weights: &[u64]) -> usize {
    let max = weights.last().unwrap();
    let n = rng.gen_range(0..*max);
    match weights.binary_search(&n) {
        Ok(idx) => idx + 1,
        Err(idx) => idx,
    }
}
pub ( crate ) fn choose_weighted ( rng : & mut RngType , weights : & [ u64 ] ) -> usize { let max = weights . last ( ) . unwrap ( ) ; let n = rng . gen_range ( 0 .. * max ) ; match weights . binary_search ( & n ) { Ok ( idx ) => idx + 1 , Err ( idx ) => idx , } }
Return chosen index based on `weights`.
Return chosen index based on ` weights ` .
rng
&mut RngType
weights
&[u64]
rng
&mut RngType
weights
&[u64]