use crate::depot::queue::{group::map, links};
impl map::Link {
#[inline(always)]
pub(super) fn leaf<'a, const LANES: usize>(
&'a self,
branches: &'a map::Branches<LANES>,
key: u64,
) -> (&'a map::Node<map::Tag>, Option<map::Place>) {
let mut node = match self {
Self::Owner(owner) => return (owner, None),
Self::Branch(node) => node,
};
let mut parent = None;
loop {
let branch: &map::Branch = node.bind(branches);
match branch.child(key) {
Self::Owner(owner) => return (owner, Some((node.index(), parent))),
Self::Branch(child) => {
parent = Some(node.index());
node = child;
}
}
}
}
pub(super) fn edge<'a, const LANES: usize>(
&'a mut self,
branches: &'a mut map::Branches<LANES>,
parent: Option<links::Index>,
key: u64,
) -> &'a mut Self {
match parent {
Some(index) => map::Node::<map::BranchTag>::new(index)
.bind(branches)
.into_mut()
.child_mut(key),
None => self,
}
}
}