def past_normalized_generic

bendvy-ecs-core@0.1.0.3 · machine_stream_queue.bend:40

import bendvy-ecs-core@0.1.0.3/machine_stream_queue.bend as MachineStreamQueue
import Base

40# Match the canonical two-pass policy even for non-monotonic supplied ticks:
41# first remove the expired prefix, then evict whole batches for capacity only.
42def past_normalized_generic(-E:Data,queue:Queue<E>,+boundary:Nat,ih:Queue<E> -> Queue<E>) -> Queue<E>:
43  match queue:
44    case Queue{Nil{},back,size,dropped,batches}:Queue{[],back,size,dropped,batches}
45    case Queue{Batch{+tick,+count,+items} <> +rest,+back,+size,+dropped,+batches}:trim_step_generic(E,Nat.is_le(tick,boundary),tick,count,items,rest,back,size,dropped,batches,ih)

Uses (6)

Used by (2)