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 533)
526 pub unsafe fn take(&mut self) -> Option<BstNodeRef<marker::Owned, Spec>> {
527 let child = unsafe { self.node.node.as_mut().child.get_unchecked_mut(Dir::IDX) };
528 child.take().map(|node| {
529 let mut node = BstNodeRef {
530 node,
531 _marker: PhantomData,
532 };
533 Spec::Parent::take_parent(node.borrow_mut());
534 node
535 })
536 }
537 pub unsafe fn replace(
538 &mut self,
539 mut other: BstNodeRef<marker::Owned, Spec>,
540 ) -> Option<BstNodeRef<marker::Owned, Spec>> {
541 let child = unsafe { self.node.node.as_mut().child.get_unchecked_mut(Dir::IDX) };
542 Spec::Parent::set_parent(other.borrow_mut(), Some(self.node.node));
543 child.replace(other.node).map(|node| {
544 let mut node = BstNodeRef {
545 node,
546 _marker: PhantomData,
547 };
548 Spec::Parent::take_parent(node.borrow_mut());
549 node
550 })
551 }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 542)
537 pub unsafe fn replace(
538 &mut self,
539 mut other: BstNodeRef<marker::Owned, Spec>,
540 ) -> Option<BstNodeRef<marker::Owned, Spec>> {
541 let child = unsafe { self.node.node.as_mut().child.get_unchecked_mut(Dir::IDX) };
542 Spec::Parent::set_parent(other.borrow_mut(), Some(self.node.node));
543 child.replace(other.node).map(|node| {
544 let mut node = BstNodeRef {
545 node,
546 _marker: PhantomData,
547 };
548 Spec::Parent::take_parent(node.borrow_mut());
549 node
550 })
551 }
552 pub unsafe fn set(&mut self, mut other: BstNodeRef<marker::Owned, Spec>) {
553 let child = unsafe { self.node.node.as_mut().child.get_unchecked_mut(Dir::IDX) };
554 Spec::Parent::set_parent(other.borrow_mut(), Some(self.node.node));
555 *child = Some(other.node);
556 }Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.