From 18e4ca440cf1b9d8d20e3e24bac0c55bbd9efada Mon Sep 17 00:00:00 2001 From: Guillermo Ramos Date: Sun, 16 Mar 2025 13:30:13 +0100 Subject: Add updates --- src/lib.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src/lib.rs') diff --git a/src/lib.rs b/src/lib.rs index cf8240c..39f225f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,3 @@ -use std::collections::HashMap; use std::fmt; use std::ops::AddAssign; @@ -234,7 +233,7 @@ pub struct PeriodicUpdate { #[derive(Debug, Default, Serialize, Deserialize)] pub struct SimUpdates { periodic: Vec, - by_month: HashMap, + by_month: Vec<(u32, SimUpdate)>, } impl SimUpdates { @@ -257,8 +256,8 @@ impl SimUpdates { ret.push(*update); } } - if let Some(update) = by_month.get(&month) { - ret.push(*update); + for update in by_month.iter().filter(|(m, _u)| *m == month) { + ret.push(update.1); } // println!(" {self:?}.get({month}) -> {ret:?}"); ret @@ -269,7 +268,7 @@ impl SimUpdates { self.periodic.push(p.clone()); } for (k, v) in other.by_month { - self.by_month.insert(k, v); + self.by_month.push((k, v)); } self } @@ -309,7 +308,7 @@ impl SimUpdate { pub fn at(&self, month: u32) -> SimUpdates { let mut updates = SimUpdates::default(); - updates.by_month.insert(month, *self); + updates.by_month.push((month, *self)); updates } } -- cgit v1.2.3