AVL_FIND(3AVL) AVL Tree Library Functions AVL_FIND(3AVL)

avl_findfind a node in an AVL tree

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

void *
avl_find(avl_tree_t *tree, const void *node, avl_index_t *where);

The () function is used to look up a node in the tree rooted at tree.

To perform a lookup, a caller should construct an instance of the data structure, the argument node. () searches through the tree for a node which compares equal to the passed in node using the comparison function specified when the tree was created with avl_create(3AVL). The only fields of node that need to be initialized are those that the comparison function will use, the others may remain uninitialized.

If a match exists in the tree, then that entry will be returned. Otherwise, NULL is returned.

If node does not match anything in the tree and the value of where is a non-NULL pointer, then where will be updated to a value that can be used with both avl_insert(3AVL) and avl_nearest(3AVL). This value is only valid as long as the tree is not modified. If anything is added or removed from the tree, then the value of where is no longer valid. This is commonly used as part of a pattern to see if something that should be added to the tree already exists, and if not, insert it. For more information, see the examples in libavl(3LIB).

If the lookup is successful, then the contents of where are undefined.

If node matches an entry in the tree, the matching entry is returned. Otherwise, NULL is returned and if where is non-NULL, it is updated to point to a location in the tree.

See the EXAMPLES section in libavl(3LIB).

See Locking in libavl(3LIB).

avl_create(3AVL), avl_insert(3AVL), avl_nearest(3AVL), libavl(3LIB)

May 7, 2015 OmniOS