picoquic/picosplay.c
void picosplay_delete_hint(picosplay_tree_t *tree, picosplay_node_t *node) {
    if(node == NULL)
        return;
    splay(tree, node); /* Now node is tree's root. */
    if(node->left == NULL) {
        tree->root = node->right;
        if(tree->root != NULL)
            tree->root->parent = NULL;
    } else if(node->right == NULL) {
        tree->root = node->left;
        tree->root->parent = NULL;
    } else {
        picosplay_node_t *x = leftmost(node->right);
        if(x->parent != node) {
            x->parent->left = x->right;
            if(x->right != NULL)
                x->right->parent = x->parent;
            x->right = node->right;
            x->right->parent = x;
        }
        tree->root = x;
        x->parent = NULL;
        x->left = node->left;
        x->left->parent = x;
    }
    tree->delete_node(tree, node);
    tree->size--;
}
/* Remove the node given by the pointer, splaying the tree. */
Remove the node given by the pointer, splaying the tree.
Remove the node given by the pointer splaying the tree .
void picosplay_delete_hint(picosplay_tree_t *tree, picosplay_node_t *node) {
    if(node == NULL)
        return;
    splay(tree, node); 
    if(node->left == NULL) {
        tree->root = node->right;
        if(tree->root != NULL)
            tree->root->parent = NULL;
    } else if(node->right == NULL) {
        tree->root = node->left;
        tree->root->parent = NULL;
    } else {
        picosplay_node_t *x = leftmost(node->right);
        if(x->parent != node) {
            x->parent->left = x->right;
            if(x->right != NULL)
                x->right->parent = x->parent;
            x->right = node->right;
            x->right->parent = x;
        }
        tree->root = x;
        x->parent = NULL;
        x->left = node->left;
        x->left->parent = x;
    }
    tree->delete_node(tree, node);
    tree->size--;
}
void picosplay_delete_hint ( picosplay_tree_t * tree , picosplay_node_t * node ) { if ( node == NULL ) return ; splay ( tree , node ) ; if ( node -> left == NULL ) { tree -> root = node -> right ; if ( tree -> root != NULL ) tree -> root -> parent = NULL ; } else if ( node -> right == NULL ) { tree -> root = node -> left ; tree -> root -> parent = NULL ; } else { picosplay_node_t * x = leftmost ( node -> right ) ; if ( x -> parent != node ) { x -> parent -> left = x -> right ; if ( x -> right != NULL ) x -> right -> parent = x -> parent ; x -> right = node -> right ; x -> right -> parent = x ; } tree -> root = x ; x -> parent = NULL ; x -> left = node -> left ; x -> left -> parent = x ; } tree -> delete_node ( tree , node ) ; tree -> size -- ; }
Remove the node given by the pointer, splaying the tree.
Remove the node given by the pointer splaying the tree .
/* Now node is tree's root. */