fn gen_lookup_table(aa: &[(u8, f32)]) -> Vec<u8> {
        let mut table = Vec::with_capacity(Rng::max_value() as usize + 1);

        let mut cumulative_prob = 0.0;
        let mut cumulative_norm = 0;

        for &(byte, prob) in aa {
            let last_norm = cumulative_norm;
            cumulative_prob += prob;
            cumulative_norm = min(Rng::max_value(), Rng::normalize(cumulative_prob)) + 1;

            table.extend((0..cumulative_norm - last_norm).map(|_| byte));
        }

        table
    }
// There's another secret technique in use here:
// we generate a lookup table to cache search of the
// aa buffer.
//
// The secret technique used is stolen from Haskell's
// implementation, and is the main secret to the Haskell
// implementation's  speed.
There's another secret technique in use here:
we generate a lookup table to cache search of the
aa buffer.

The secret technique used is stolen from Haskell's
implementation, and is the main secret to the Haskell
implementation's  speed.
There ' s another secret technique in use here : we generate a lookup table to cache search of the aa buffer . The secret technique used is stolen from Haskell ' s implementation and is the main secret to the Haskell implementation ' s speed .
fn gen_lookup_table(aa: &[(u8, f32)]) -> Vec<u8> {
        let mut table = Vec::with_capacity(Rng::max_value() as usize + 1);
        let mut cumulative_prob = 0.0;
        let mut cumulative_norm = 0;
        for &(byte, prob) in aa {
            let last_norm = cumulative_norm;
            cumulative_prob += prob;
            cumulative_norm = min(Rng::max_value(), Rng::normalize(cumulative_prob)) + 1;
            table.extend((0..cumulative_norm - last_norm).map(|_| byte));
        }
        table
    }
fn gen_lookup_table ( aa : & [ ( u8 , f32 ) ] ) -> Vec < u8 > { let mut table = Vec :: with_capacity ( Rng :: max_value ( ) as usize + 1 ) ; let mut cumulative_prob = 0.0 ; let mut cumulative_norm = 0 ; for & ( byte , prob ) in aa { let last_norm = cumulative_norm ; cumulative_prob += prob ; cumulative_norm = min ( Rng :: max_value ( ) , Rng :: normalize ( cumulative_prob ) ) + 1 ; table . extend ( ( 0 .. cumulative_norm - last_norm ) . map ( | _ | byte ) ) ; } table }
There's another secret technique in use here:
we generate a lookup table to cache search of the
aa buffer.
There ' s another secret technique in use here : we generate a lookup table to cache search of the aa buffer .
aa
&[(u8, f32)]