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

**Committed**

**MT-Level**

See__Locking__ in libavl(3LIB).

## SEE ALSO

libavl(3LIB)

illumos May 7, 2015 illumos

AVL Tree Library (libavl, -lavl)

The

the insertion point specified by

The value of

If

followed it will be returned. If

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

If the tree is modified between a call to avl_find(3AVL) and

then the value of

avl_find(3AVL) must be called again.

The

there is not a matching one.

See the

See

libavl(3LIB)

illumos May 7, 2015 illumos