use std::collections::HashMap;
use super::YearSet;
pub type PersonId = u32;
#[derive(Clone, Default, Eq, PartialEq)]
pub struct ContributorSet(HashMap<PersonId, YearSet>);
impl ContributorSet {
pub fn insert(&mut self, person: PersonId, timestamp: i64) {
self.0
.entry(person)
.or_default()
.insert_timestamp_year(timestamp)
}
pub fn merge(&mut self, other: &Self) {
for (person, years) in &other.0 {
self.0.entry(*person).or_default().merge(years)
}
}
}
impl IntoIterator for ContributorSet {
type Item = (PersonId, YearSet);
type IntoIter = <HashMap<PersonId, YearSet> as IntoIterator>::IntoIter;
fn into_iter(self) -> Self::IntoIter {
self.0.into_iter()
}
}