picoquic/picosplay.c
picosplay_node_t* picosplay_insert(picosplay_tree_t *tree, void *value) {
    picosplay_node_t *new = tree->create(value);

    if (new != NULL) {
        new->left = NULL;
        new->right = NULL;
        if (tree->root == NULL) {
            tree->root = new;
            new->parent = NULL;
        }
        else {
            picosplay_node_t *curr = tree->root;
            picosplay_node_t *parent = NULL;
            int left = 0;
            while (curr != NULL) {
                parent = curr;
                if (tree->comp(tree->node_value(new), tree->node_value(curr)) < 0) {
                    left = 1;
                    curr = curr->left;
                }
                else {
                    left = 0;
                    curr = curr->right;
                }
            }
            new->parent = parent;
            if (left)
                parent->left = new;
            else
                parent->right = new;
        }
        splay(tree, new);
        tree->size++;
    }

    return new;
}
/* picosplay_insert and return a new node with the given value, splaying the tree. 
 * The insertion is essentially a generic BST insertion.
 */
picosplay_insert and return a new node with the given value, splaying the tree.
The insertion is essentially a generic BST insertion.
picosplay_insert and return a new node with the given value splaying the tree . The insertion is essentially a generic BST insertion .
picosplay_node_t* picosplay_insert(picosplay_tree_t *tree, void *value) {
    picosplay_node_t *new = tree->create(value);
    if (new != NULL) {
        new->left = NULL;
        new->right = NULL;
        if (tree->root == NULL) {
            tree->root = new;
            new->parent = NULL;
        }
        else {
            picosplay_node_t *curr = tree->root;
            picosplay_node_t *parent = NULL;
            int left = 0;
            while (curr != NULL) {
                parent = curr;
                if (tree->comp(tree->node_value(new), tree->node_value(curr)) < 0) {
                    left = 1;
                    curr = curr->left;
                }
                else {
                    left = 0;
                    curr = curr->right;
                }
            }
            new->parent = parent;
            if (left)
                parent->left = new;
            else
                parent->right = new;
        }
        splay(tree, new);
        tree->size++;
    }
    return new;
}
picosplay_node_t * picosplay_insert ( picosplay_tree_t * tree , void * value ) { picosplay_node_t * new = tree -> create ( value ) ; if ( new != NULL ) { new -> left = NULL ; new -> right = NULL ; if ( tree -> root == NULL ) { tree -> root = new ; new -> parent = NULL ; } else { picosplay_node_t * curr = tree -> root ; picosplay_node_t * parent = NULL ; int left = 0 ; while ( curr != NULL ) { parent = curr ; if ( tree -> comp ( tree -> node_value ( new ) , tree -> node_value ( curr ) ) < 0 ) { left = 1 ; curr = curr -> left ; } else { left = 0 ; curr = curr -> right ; } } new -> parent = parent ; if ( left ) parent -> left = new ; else parent -> right = new ; } splay ( tree , new ) ; tree -> size ++ ; } return new ; }
picosplay_insert and return a new node with the given value, splaying the tree.
picosplay_insert and return a new node with the given value splaying the tree .