AVL_INSERT(3AVL) AVL Tree Library Functions AVL_INSERT(3AVL)

NAME


avl_insert, avl_insert_here - insert items into an AVL tree

SYNOPSIS


AVL Tree Library (libavl, -lavl)
#include <sys/avl.h>

void
avl_insert(avl_tree_t *tree, void *new, avl_index_t where);

void
avl_insert_here(avl_tree_t *tree, void *new, void *here, int direction);

DESCRIPTION


The avl_insert() and avl_insert_here() functions are used to add the entry
new to the tree rooted at tree.

The avl_insert() function uses the where value, obtained from a call to
avl_find(3AVL), to determine where to insert the new entry into the tree.
The tree must not have been modified in between the call to avl_find(3AVL)
and the call to avl_insert(). If callers are not using avl_find(3AVL) to
validate the presence of new in the tree and only immediately insert it,
then avl_add(3AVL) may be used instead.

The avl_insert_here() function is for consumers who are keeping track of
recently accessed data and wish to avoid an additional call to
avl_find(3AVL). The new entry, new, will be inserted starting at the node
here, which must already exist in the tree. To insert the node in the tree
before here, then the argument direction should have the value AVL_BEFORE.
Otherwise, to indicate that the new entry should be inserted after here,
then direction should be set to AVL_AFTER. It is illegal to set direction
to anything other than AVL_BEFORE or AVL_AFTER. If this is done, the
behavior is not defined.

EXAMPLES


See the EXAMPLES section in libavl(3LIB).

INTERFACE STABILITY


Committed

MT-Level
See Locking in libavl(3LIB).

SEE ALSO


avl_add(3AVL), avl_find(3AVL), libavl(3LIB)

illumos May 7, 2015 illumos