pub struct ArrivalLog { /* private fields */ }Expand description
Append-only log of per-stop arrival events used to compute rolling arrival-rate signals.
Stored as a Vec<(tick, stop)> sorted by tick (records are appended
in tick order during normal sim execution). Queries are O(n) worst
case but typically O(window_size); prune_before keeps the tail
short enough that this is a non-issue for practical window sizes.
Implementations§
Source§impl ArrivalLog
impl ArrivalLog
Sourcepub fn arrivals_in_window(
&self,
stop: EntityId,
now: u64,
window_ticks: u64,
) -> u64
pub fn arrivals_in_window( &self, stop: EntityId, now: u64, window_ticks: u64, ) -> u64
Count arrivals at stop within the window [now - window, now]
inclusive. window_ticks = 0 always returns 0.
Sourcepub fn prune_before(&mut self, cutoff: u64)
pub fn prune_before(&mut self, cutoff: u64)
Drop every entry with tick strictly before cutoff. Called each
tick by the sim with cutoff = current_tick - max_window so the
log can’t grow without bound.
Sourcepub const fn len(&self) -> usize
pub const fn len(&self) -> usize
Number of recorded events currently in the log. Intended for snapshot inspection and tests.
Sourcepub fn remap_entity_ids(&mut self, id_remap: &HashMap<EntityId, EntityId>)
pub fn remap_entity_ids(&mut self, id_remap: &HashMap<EntityId, EntityId>)
Rewrite every entry’s stop EntityId through id_remap, dropping
entries whose stop isn’t present in the map. Used by snapshot
restore to translate pre-restore stop IDs to the new allocations.
Trait Implementations§
Source§impl Clone for ArrivalLog
impl Clone for ArrivalLog
Source§fn clone(&self) -> ArrivalLog
fn clone(&self) -> ArrivalLog
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more