Expand description
Simple event simulation helpers over finite event lists.
Events are modeled as time and change pairs. The runtime sorts them by time and applies each change to a scalar state.
§Examples
use use_event_simulation::{run_event_simulation, SimulationEvent};
let states = run_event_simulation(
10.0,
&[
SimulationEvent::new(2.0, -1.0).unwrap(),
SimulationEvent::new(1.0, 3.0).unwrap(),
],
)
.unwrap();
assert_eq!(states[0].state, 10.0);
assert_eq!(states[1].time, 1.0);
assert_eq!(states[2].state, 12.0);