use crate::core::{Id, Ordinal, Tactic};
#[derive(Debug)]
pub struct Compromise {
compromises: Vec<Id>,
}
impl Compromise {
#[must_use]
pub const fn new(compromises: Vec<Id>) -> Self {
Self { compromises }
}
}
impl Tactic<Ordinal> for Compromise {
fn apply(&self, ballot: Ordinal) -> Ordinal {
let mut compromised_ranking: Vec<Id> = (*ballot).clone();
compromised_ranking.retain(|c| !self.compromises.contains(c));
let mut ranking = self.compromises.clone();
ranking.append(&mut compromised_ranking);
Ordinal(ranking)
}
}