use alloc::collections::BTreeSet;
use alloc::vec::Vec;
use discrete_range_map::{
discrete_range_map::{PointType, RangeType},
InclusiveInterval,
};
pub trait GapQueryIntervalTree<I, K, D> {
#[doc=include_str!("../images/gap-query.svg")]
fn gap_query<Q>(&self, with_identifier: Option<D>, interval: Q) -> Vec<K>
where
Q: RangeType<I>;
#[doc=include_str!("../images/insertion.svg")]
fn insert(&mut self, identifiers: BTreeSet<D>, interval: K);
#[doc=include_str!("../images/removal.svg")]
fn cut<Q>(&mut self, with_identifiers: Option<BTreeSet<D>>, interval: Q)
where
Q: RangeType<I>;
fn append(&mut self, other: &mut Self);
fn gap_query_at_point(&self, with_identifier: Option<D>, at_point: I) -> Option<K>
where
I: PointType,
{
let mut overlapping = self.gap_query(
with_identifier,
InclusiveInterval {
start: at_point,
end: at_point,
},
);
assert!(overlapping.is_empty() || overlapping.len() == 1);
overlapping.pop()
}
fn identifiers_at_point(&self, at_point: I) -> BTreeSet<D>
where
D: Copy;
}