def Zone.find

bend-kit-time@0.3.0.0 · time.bend:1148

import bend-kit-time@0.3.0.0/time.bend as Time
import Base
import bend-kit-int@0.2.0.0/int.bend as Int

1148# The type index at secs: the last transition at or before it, or type 0 before the first.
1149# ponytail: linear scan; bisect an Array if lookups get hot.
1150def Zone.find(ts: List<&2, Trans>, +secs: Int.I64, +cur: U32) -> U32:
1151  match ts:
1152    case Nil{}:
1153      cur
1154    case Con{Trans{t, k}, rest}:
1155      Zone.find(rest, secs, Bool.pick(U32, Int.I64.is_le(t, secs), k, cur))

Uses (6)

Used by (3)