use super::*;
pub type Vistr<'a, N> = compt::dfs_order::Vistr<'a, N, compt::dfs_order::PreOrder>;
mod vistr_mut {
use super::*;
use compt::Visitor;
#[repr(transparent)]
#[must_use]
pub struct VistrMutPin<'a, N> {
inner: compt::dfs_order::VistrMut<'a, N, compt::dfs_order::PreOrder>,
}
impl<'a, N> VistrMutPin<'a, N> {
#[inline(always)]
pub fn new(inner: compt::dfs_order::VistrMut<'a, N, compt::dfs_order::PreOrder>) -> Self {
VistrMutPin { inner }
}
#[inline(always)]
pub fn borrow_mut(&mut self) -> VistrMutPin<N> {
VistrMutPin {
inner: self.inner.borrow_mut(),
}
}
#[inline(always)]
pub fn borrow(&self) -> Vistr<N> {
self.inner.borrow()
}
#[inline(always)]
pub fn get_height(&self) -> usize {
compt::FixedDepthVisitor::get_height(self)
}
#[inline(always)]
pub fn into_slice(self) -> AabbPin<&'a mut [N]> {
AabbPin::new(self.inner.into_slice())
}
}
impl<'a, N> compt::FixedDepthVisitor for VistrMutPin<'a, N> {}
impl<'a, N> Visitor for VistrMutPin<'a, N> {
type Item = AabbPin<&'a mut N>;
#[inline(always)]
fn next(self) -> (Self::Item, Option<[Self; 2]>) {
let (nn, rest) = self.inner.next();
let k = rest
.map(|[left, right]| [VistrMutPin { inner: left }, VistrMutPin { inner: right }]);
(AabbPin::new(nn), k)
}
#[inline(always)]
fn level_remaining_hint(&self) -> (usize, Option<usize>) {
self.inner.level_remaining_hint()
}
}
}
pub use vistr_mut::VistrMutPin;
pub struct Node<'a, T, N> {
pub range: AabbPin<&'a mut [T]>,
pub cont: axgeom::Range<N>,
pub div: Option<N>,
pub min_elem: usize,
}
impl<'a, T, N: Num> Node<'a, T, N> {
pub fn borrow_range(&mut self) -> AabbPin<&mut [T]> {
self.range.borrow_mut()
}
pub fn as_data(&self) -> NodeData<N> {
NodeData {
range: self.range.len(),
cont: self.cont,
div: self.div,
min_elem: self.min_elem,
}
}
}
#[derive(Debug, Clone)]
pub struct NodeData<N: Num> {
pub range: usize,
pub cont: axgeom::Range<N>,
pub div: Option<N>,
pub min_elem: usize,
}