picoquic/picosplay.c
picosplay_node_t* picosplay_find(picosplay_tree_t *tree, void *value)
{
    picosplay_node_t *curr = tree->root;
    int found = 0;
    while(curr != NULL && !found) {
        int64_t relation = tree->comp(value, tree->node_value(curr));
        if(relation == 0) {
            found = 1;
        } else if(relation < 0) {
            curr = curr->left;
        } else {
            curr = curr->right;
        }
    }

    /* TODO: there may or may not be a need to perform a splay on a find operation.
     * The Wikipedia example omits it, but this code keeps it. We should
     * perform measurements with and without it and keep the best alternative. */
    if(curr != NULL)
        splay(tree, curr);
    return curr;
}
/* Find a node with the given value, splaying the tree. */
Find a node with the given value, splaying the tree.
Find a node with the given value splaying the tree .
picosplay_node_t* picosplay_find(picosplay_tree_t *tree, void *value)
{
    picosplay_node_t *curr = tree->root;
    int found = 0;
    while(curr != NULL && !found) {
        int64_t relation = tree->comp(value, tree->node_value(curr));
        if(relation == 0) {
            found = 1;
        } else if(relation < 0) {
            curr = curr->left;
        } else {
            curr = curr->right;
        }
    }
    if(curr != NULL)
        splay(tree, curr);
    return curr;
}
picosplay_node_t * picosplay_find ( picosplay_tree_t * tree , void * value ) { picosplay_node_t * curr = tree -> root ; int found = 0 ; while ( curr != NULL && ! found ) { int64_t relation = tree -> comp ( value , tree -> node_value ( curr ) ) ; if ( relation == 0 ) { found = 1 ; } else if ( relation < 0 ) { curr = curr -> left ; } else { curr = curr -> right ; } } if ( curr != NULL ) splay ( tree , curr ) ; return curr ; }
Find a node with the given value, splaying the tree.
Find a node with the given value splaying the tree .
/* TODO: there may or may not be a need to perform a splay on a find operation.
     * The Wikipedia example omits it, but this code keeps it. We should
     * perform measurements with and without it and keep the best alternative. */