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

View File

@ -250,13 +250,17 @@ 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() {
println!("{}. {}", i + 1, winner.name);
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);
}
}
}