AVL_NEAREST(3AVL) AVL Tree Library Functions AVL_NEAREST(3AVL)
NAME
avl_nearest - find the nearest node in an AVL tree
SYNOPSIS
AVL Tree Library (libavl, -lavl)
#include <sys/avl.h> void * avl_nearest(
avl_tree_t *tree,
avl_index_t where,
int direction);
DESCRIPTION
The
avl_nearest function returns the closest node in
tree before or after
the insertion point specified by
where.
The value of
where is obtained when a non-NULL pointer is passed in to the
where argument of
avl_find(3AVL) and it fails to find an entry in the tree.
If
direction is set to AVL_AFTER, then the node that would logically have
followed it will be returned. If
direction is instead set to AVL_BEFORE,
then the node that would have logically preceded it is returned.
When there is no nearest node, for example, AVL_AFTER is specified and the
entry would have been the last node in the tree, then
NULL is returned.
If the tree is modified between a call to
avl_find(3AVL) and
avl_nearest(),
then the value of
where from
avl_find(3AVL) will no longer be valid and
avl_find(3AVL) must be called again.
RETURN VALUES
The
avl_nearest() function returns the node that is closest or
NULL if
there is not a matching one.
EXAMPLES
See the
EXAMPLES section in
libavl(3LIB).
INTERFACE STABILITY
CommittedMT-Level See
Locking in
libavl(3LIB).
SEE ALSO
libavl(3LIB)illumos May 7, 2015 illumos