MCPcopy Create free account
hub / github.com/QMHTMY/RustBook / replace_node

Function replace_node

publication/code/chapter08/rbtree.rs:880–893  ·  view source on GitHub ↗
(
    tree: &mut RBTree<K, V>,
    parent: *mut RBNode<K, V>,
    node: *mut RBNode<K, V>,
    new: *mut RBNode<K, V>)

Source from the content-addressed store, hash-verified

878// 替换节点值并更新节点关系
879#[inline]
880unsafe fn replace_node<K: Ord + Debug, V>(
881 tree: &mut RBTree<K, V>,
882 parent: *mut RBNode<K, V>,
883 node: *mut RBNode<K, V>,
884 new: *mut RBNode<K, V>)
885{
886 if parent.is_null() {
887 tree.root = new;
888 } else if (*parent).left == node {
889 (*parent).left = new;
890 } else {
891 (*parent).right = new;
892 }
893}
894
895fn main() {
896 fn basic() {

Callers 1

deleteMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected