pub trait ParentStrategy: Sized + Default {
type Data;
// Provided methods
fn take_parent<Spec>(_node: BstNodeRef<Mut<'_>, Spec>)
where Spec: BstSpec<Data = Self::Data, Parent = Self> { ... }
fn set_parent<Spec>(
_node: BstNodeRef<Mut<'_>, Spec>,
_parent: Option<NonNull<BstNode<Spec::Data, Self>>>,
)
where Spec: BstSpec<Data = Self::Data, Parent = Self> { ... }
}Required Associated Types§
Provided Methods§
Sourcefn take_parent<Spec>(_node: BstNodeRef<Mut<'_>, Spec>)
fn take_parent<Spec>(_node: BstNodeRef<Mut<'_>, Spec>)
Examples found in repository?
crates/competitive/src/data_structure/binary_search_tree/node.rs (line 549)
542 pub unsafe fn take(&mut self) -> Option<BstNodeRef<marker::Owned, Spec>> {
543 let child = unsafe { self.node.node.as_mut().child.get_unchecked_mut(Dir::IDX) };
544 child.take().map(|node| {
545 let mut node = BstNodeRef {
546 node,
547 _marker: PhantomData,
548 };
549 Spec::Parent::take_parent(node.borrow_mut());
550 node
551 })
552 }
553 pub unsafe fn replace(
554 &mut self,
555 mut other: BstNodeRef<marker::Owned, Spec>,
556 ) -> Option<BstNodeRef<marker::Owned, Spec>> {
557 let child = unsafe { self.node.node.as_mut().child.get_unchecked_mut(Dir::IDX) };
558 Spec::Parent::set_parent(other.borrow_mut(), Some(self.node.node));
559 child.replace(other.node).map(|node| {
560 let mut node = BstNodeRef {
561 node,
562 _marker: PhantomData,
563 };
564 Spec::Parent::take_parent(node.borrow_mut());
565 node
566 })
567 }Sourcefn set_parent<Spec>(
_node: BstNodeRef<Mut<'_>, Spec>,
_parent: Option<NonNull<BstNode<Spec::Data, Self>>>,
)
fn set_parent<Spec>( _node: BstNodeRef<Mut<'_>, Spec>, _parent: Option<NonNull<BstNode<Spec::Data, Self>>>, )
Examples found in repository?
crates/competitive/src/data_structure/binary_search_tree/node.rs (line 558)
553 pub unsafe fn replace(
554 &mut self,
555 mut other: BstNodeRef<marker::Owned, Spec>,
556 ) -> Option<BstNodeRef<marker::Owned, Spec>> {
557 let child = unsafe { self.node.node.as_mut().child.get_unchecked_mut(Dir::IDX) };
558 Spec::Parent::set_parent(other.borrow_mut(), Some(self.node.node));
559 child.replace(other.node).map(|node| {
560 let mut node = BstNodeRef {
561 node,
562 _marker: PhantomData,
563 };
564 Spec::Parent::take_parent(node.borrow_mut());
565 node
566 })
567 }
568 pub unsafe fn set(&mut self, mut other: BstNodeRef<marker::Owned, Spec>) {
569 let child = unsafe { self.node.node.as_mut().child.get_unchecked_mut(Dir::IDX) };
570 Spec::Parent::set_parent(other.borrow_mut(), Some(self.node.node));
571 *child = Some(other.node);
572 }Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".