- while tot_w > (1 << max_bits) {
- for w in stats.iter_mut() {
- *w = (*w + 1) >> 1;
- }
- tot_w = 0;
- for &w in stats.iter() {
- tot_w += w;
+ loop {
+ let mut tree = Tree::new();
+ for (sym, &w) in stats.iter().enumerate() {
+ tree.insert(Node{ sym: sym as u16, w: w as u16, idx0: 64000, idx1: 64000 });