Skip to main content

complement_within

Function complement_within 

Source
pub fn complement_within<T>(
    outer: Interval<T>,
    periods: &[Interval<T>],
) -> Vec<Interval<T>>
where T: TimeInstant,
Expand description

Returns the gaps (complement) of periods within the bounding outer period.

Given a sorted, non-overlapping list of sub-periods and a bounding period, this returns the time intervals NOT covered by any sub-period.

Both outer and every element of periods must have start <= end. The function runs in O(n) time with a single pass.

§Arguments

  • outer - The bounding period
  • periods - Sorted, non-overlapping sub-periods within outer

§Returns

The complement periods (gaps) in chronological order.