AVL_NEAREST(3AVL) AVL Tree Library Functions AVL_NEAREST(3AVL)
- find the nearest node in an AVL tree
AVL Tree Library (libavl, -lavl) #include <sys/avl.h> void * avl_nearest
, avl_index_t where
, int direction
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.
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)
then the value of where
will no longer be valid and avl_find(3AVL)
must be called again.
() function returns the node that is closest or NULL
there is not a matching one.
See the EXAMPLES
section in libavl(3LIB)
INTERFACE STABILITY CommittedMT-Level
SEE ALSO libavl(3LIB)
illumos May 7, 2015 illumos