pub fn are_intervals_contiguous(intervals: &[(u64, u64)]) -> bool
Expand description
Checks if intervals are contiguous (adjacent with no gaps).
Intervals are contiguous if, when sorted by start time, each interval’s start timestamp is exactly one more than the previous interval’s end timestamp. This ensures complete coverage of a time range with no gaps.
§Parameters
intervals
: A slice of timestamp intervals as (start, end) tuples.
§Returns
Returns true
if all intervals are contiguous, false
if any gaps are found.
Returns true
for empty lists or lists with a single interval.
§Examples
// Contiguous intervals
assert!(are_intervals_contiguous(&[(1, 5), (6, 10), (11, 15)]));
// Non-contiguous intervals (gap between 5 and 8)
assert!(!are_intervals_contiguous(&[(1, 5), (8, 10)]));