int_interval_stack/int_co_stack/
impls_for_predicates.rs1use super::*;
2
3impl<I> IntCOStack<I>
4where
5 I: IntCO,
6{
7 #[inline]
8 pub fn is_empty(&self) -> bool {
9 self.points.is_empty()
10 }
11
12 #[inline]
13 pub fn contains_point(&self, x: I::CoordType) -> bool {
14 self.height_at(x) != 0
15 }
16
17 pub fn intersects_interval<Q>(&self, query: Q) -> bool
18 where
19 Q: IntCO<CoordType = I::CoordType>,
20 {
21 if query.start() >= query.end_excl() {
22 return false;
23 }
24
25 if self.height_at(query.start()) != 0 {
26 return true;
27 }
28
29 let i = self.points.partition_point(|p| p.at <= query.start());
30
31 self.points[i..]
32 .iter()
33 .take_while(|p| p.at < query.end_excl())
34 .any(|p| p.height_after != 0)
35 }
36
37 pub fn contains_interval<Q>(&self, query: Q) -> bool
38 where
39 Q: IntCO<CoordType = I::CoordType>,
40 {
41 if query.start() >= query.end_excl() {
42 return true;
43 }
44
45 if self.height_at(query.start()) == 0 {
46 return false;
47 }
48
49 let i = self.points.partition_point(|p| p.at <= query.start());
50
51 !self.points[i..]
52 .iter()
53 .take_while(|p| p.at < query.end_excl())
54 .any(|p| p.height_after == 0)
55 }
56}
57#[cfg(test)]
58mod tests_for_predicates;