Representing Intervals as Pairs
An interval record holds endpoints and an agreed convention about whether each is included.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 4
- Reading time
- 1 min
In this article4 chapters
Reason about contact at a boundary
Intervals \([2,5)\) and \([5,8)\) meet at five without sharing a position. They model neighboring time slots with exact handoff. Inclusive and exclusive comparisons determine the intersection rule.
Check overlap generally
For positive-length half-open intervals \([a,b)\) and \([c,d)\), there is overlap when \(\max(a,c)<\min(b,d)\). An empty interval should overlap none. The record contract can state allowed empty and reversed inputs and specify their behavior.[1]
Match the endpoint rule to a concrete schedule
Time reservations [9,10) and [10,11) touch at ten without sharing a time. The same pairs interpreted as closed intervals overlap at ten. Use a written boundary convention when comparing arrivals with reservations. See inclusive versus exclusive tests.
Probe in [9,10) in [10,11)
9.5 yes no
10 no yes
11 no no
Validate shape before measuring length
For numeric half-open intervals, \([a,a)\) is empty and has length zero. A pair with \(b<a\) can be rejected rather than interpreted without a policy. State the units and whether endpoints are comparable on the same timeline.