aboutsummaryrefslogtreecommitdiff
path: root/srchr/src/layout.rs
diff options
context:
space:
mode:
Diffstat (limited to 'srchr/src/layout.rs')
-rw-r--r--srchr/src/layout.rs19
1 files changed, 14 insertions, 5 deletions
diff --git a/srchr/src/layout.rs b/srchr/src/layout.rs
index 2b8cf05..bc519c1 100644
--- a/srchr/src/layout.rs
+++ b/srchr/src/layout.rs
@@ -142,7 +142,7 @@ impl Layout {
(wcol.into_iter().map(|(k, _)| k as u8).collect(), weight)
})
.collect::<Vec<(Vec<u8>, f32)>>();
- result.sort_by(|(_, l), (_, r)| my_f32_compare(*r, *l));
+ result.sort_by(|(_, l), (_, r)| my_f32_compare(*l, *r));
result
}
@@ -151,8 +151,8 @@ impl Layout {
let mut right_col: usize = 9;
let mut keys = ['x'; NUM_KEYS];
- let mut w_standard_columns = weight_function(&pl.standard_columns, corpus);
- while let Some((col, weight)) = w_standard_columns.pop() {
+ let w_standard_columns = weight_function(&pl.standard_columns, corpus);
+ for (col, weight) in w_standard_columns.iter() {
let left: bool = ((balance >= 0.0) && (left_col <= 2)) || (right_col <= 6);
let ind = if left { left_col } else { right_col };
for i in 0..3 {
@@ -163,7 +163,7 @@ impl Layout {
} else {
right_col -= 1;
}
- balance += if left { -weight } else { weight };
+ balance += if left { -weight } else { *weight };
}
let w_index_columns = weight_function(&pl.index_columns, corpus);
@@ -194,7 +194,16 @@ impl Layout {
+ corpus.get_bigram_perc(m3, i3);
}
}
- (left_ind, right_ind) = if lsbs[0] < lsbs[1] { (0, 1) } else { (1, 0) }
+ (left_ind, right_ind) = if lsbs[0] < lsbs[1] { (0, 1) } else { (1, 0) };
+ // if this disagrees with the balancing order, let's consider ring
+ // column swaps
+ if balance >= 0.0 && left_ind == 0 && w_standard_columns[2].0[0] == keys[1] as u8 {
+ for i in 0..3 {
+ let t = keys[8 + 10 * i];
+ keys[8 + 10 * i] = keys[1 + 10 * i];
+ keys[1 + 10 * i] = t;
+ }
+ }
} else {
(left_ind, right_ind) = if balance >= 0.0 { (0, 1) } else { (1, 0) }
}