Skip to main content

int_interval_stack/int_co_stack/
impls_for_access.rs

1use super::*;
2
3impl<I> IntCOStack<I>
4where
5    I: IntCO,
6{
7    #[inline]
8    pub fn change_points(&self) -> &[ChangePoint<I::CoordType>] {
9        &self.points
10    }
11
12    pub fn height_at(&self, x: I::CoordType) -> usize {
13        let i = self.points.partition_point(|p| p.at <= x);
14        if i == 0 {
15            0
16        } else {
17            self.points[i - 1].height_after
18        }
19    }
20
21    #[inline]
22    pub fn max_height(&self) -> usize {
23        self.points
24            .iter()
25            .map(|p| p.height_after)
26            .max()
27            .unwrap_or(0)
28    }
29}
30
31#[cfg(test)]
32mod tests_for_access;