AVL_FIRST(3AVL) AVL Tree Library Functions AVL_FIRST(3AVL)

NAME


avl_first, AVL_NEXT, AVL_PREV, avl_last - get the first, next, previous,
and last entries from an AVL tree

SYNOPSIS


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

void *
avl_first(avl_tree_t *tree);

void *
avl_last(avl_tree_t *tree);

void *
AVL_NEXT(avl_tree_t *tree, void *node);

void *
AVL_PREV(avl_tree_t *tree, void *node);

DESCRIPTION


The avl_first() and avl_last() respectively return the first and last entry
in the tree specified by tree. Order in the tree is determined by the
comparison function that was specified at the time the tree was created
with avl_create(3AVL). If tree is empty, then avl_first() and avl_last()
return NULL.

The AVL_NEXT() and AVL_PREV() functions are macros that may be used to
obtain the next and previous entry following node in the AVL tree tree. If
there is no next or previous node, for example, if one was at the beginning
or end of the tree, then NULL is returned.

These constructs are generally used as part of loops to iterate the tree.
See the examples section in libavl(3LIB) for more information on using this
interface.

RETURN VALUES


The avl_first() function returns a pointer to the first entry in the AVL
tree tree or NULL if the AVL tree is empty.

The avl_last() function returns a pointer to the last entry in the AVL tree
tree or NULL if the AVL tree is empty.

The AVL_NEXT() macro returns a pointer to the object in the tree that
follows node. If node is the last entry in the tree, NULL is returned
instead.

The AVL_PREV() macro returns a pointer to the object in the tree that
precedes node. If node is the first entry in the tree, NULL is returned
instead.

EXAMPLES


See the EXAMPLES section in libavl(3LIB).

INTERFACE STABILITY


Committed

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

SEE ALSO


avl_create(3AVL), libavl(3LIB)

illumos May 7, 2015 illumos