Show keep values for elected candidates in Meek STV

This commit is contained in:
RunasSudo 2021-06-16 18:23:47 +10:00
parent d34057d03a
commit ca54b94953
No known key found for this signature in database
GPG Key ID: 7234E476BF21C61A
1 changed files with 8 additions and 4 deletions

View File

@ -250,14 +250,18 @@ where
let mut winners = Vec::new();
for (candidate, count_card) in state.candidates.iter() {
if count_card.state == CandidateState::Elected {
winners.push((candidate, count_card.order_elected));
winners.push((candidate, count_card));
}
}
winners.sort_unstable_by(|a, b| a.1.partial_cmp(&b.1).unwrap());
winners.sort_unstable_by(|a, b| a.1.order_elected.partial_cmp(&b.1.order_elected).unwrap());
for (i, (winner, _)) in winners.into_iter().enumerate() {
for (i, (winner, count_card)) in winners.into_iter().enumerate() {
if let Some(kv) = &count_card.keep_value {
println!("{}. {} (kv = {:.dps2$})", i + 1, winner.name, kv, dps2=max(stv_opts.pp_decimals, 2));
} else {
println!("{}. {}", i + 1, winner.name);
}
}
}
fn print_candidates<'a, N: 'a + Number, I: Iterator<Item=(&'a Candidate, &'a CountCard<'a, N>)>>(candidates: I, cmd_opts: &STV) {