Skip to main content

complement_within

Function complement_within 

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

Gaps inside outer that are not covered by any interval in periods.

This is a free-function wrapper around Interval::complement. periods must be sorted and non-overlapping (see Interval::validate).

ยงExample

use tempoch_core::{complement_within, JulianDate, TT, Interval};
use qtty::Day;

let outer = Interval::<JulianDate<TT>>::new(
    JulianDate::new(2_451_545.0),
    JulianDate::new(2_451_550.0),
);
let filled = vec![Interval::new(
    JulianDate::new(2_451_546.0),
    JulianDate::new(2_451_548.0),
)];
let gaps = complement_within(outer, &filled);
assert_eq!(gaps.len(), 2);