module
VirtualTime::Search
Overview
Search provides monotonic, DST-safe, policy-free temporal traversal suitable for scheduling. Stateless. Not related to other methods above. Advances by at least 1 step before evaluation.
Defined in:
virtualtime.crClass Method Summary
-
.shift_from_base(base : Time, step : Time::Span, *, domain : Domain | Nil = nil, max_shift : Time::Span | Nil = nil, max_shifts : Int32 | Nil = nil, &blocked : Time -> Bool) : Result::Result
Moves forward from
baseby repeated application ofstep(successor behavior: first candidate is base + step). -
.shifted_from_base?(target : Time, step : Time::Span, *, max_shift : Time::Span | Nil = nil, max_shifts : Int32, &producer : Time -> Time::Span | Nil) : Bool
Inverse reachability check: determine backwards whether
targetcan be obtained asbase + delta, stepping bystep.
Class Method Detail
def self.shift_from_base(base : Time, step : Time::Span, *, domain : Domain | Nil = nil, max_shift : Time::Span | Nil = nil, max_shifts : Int32 | Nil = nil, &blocked : Time -> Bool) : Result::Result
#
Moves forward from base by repeated application of step
(successor behavior: first candidate is base + step).
Returns:
Result::Foundholding the Time::Span delta to the first unblocked candidateResult::Blockedifmax_shiftsis exhausted before a candidate is acceptedResult::OutOfBoundsifmax_shiftordomainis exceededResult::InvalidStepifstepis zero
Notes:
- step must be non-zero
- max_shift bounds the returned delta (inclusive)
- max_shifts bounds the number of step applications (inclusive)
- stepping is done on Time values (DST-safe)
- the search is only as bounded as its arguments: if
domain,max_shift, andmax_shiftsare all nil and every candidate is blocked, it never returns. Supply at least one bound unless the block is certain to eventually accept a candidate.
def self.shifted_from_base?(target : Time, step : Time::Span, *, max_shift : Time::Span | Nil = nil, max_shifts : Int32, &producer : Time -> Time::Span | Nil) : Bool
#
Inverse reachability check: determine backwards whether target can be obtained as base + delta,
stepping by step. Returns bool value.
Notes:
- successor-based: first base is
target - step - max_shift bounds the produced delta (inclusive)
- max_shifts bounds number of step applications (inclusive)
- stepping is done on Time values (DST-safe)