1fa9922c2SRobert Mustacchi.\" 2fa9922c2SRobert Mustacchi.\" This file and its contents are supplied under the terms of the 3fa9922c2SRobert Mustacchi.\" Common Development and Distribution License ("CDDL"), version 1.0. 4fa9922c2SRobert Mustacchi.\" You may only use this file in accordance with the terms of version 5fa9922c2SRobert Mustacchi.\" 1.0 of the CDDL. 6fa9922c2SRobert Mustacchi.\" 7fa9922c2SRobert Mustacchi.\" A full copy of the text of the CDDL should have accompanied this 8fa9922c2SRobert Mustacchi.\" source. A copy of the CDDL is also available via the Internet at 9fa9922c2SRobert Mustacchi.\" http://www.illumos.org/license/CDDL. 10fa9922c2SRobert Mustacchi.\" 11fa9922c2SRobert Mustacchi.\" 12fa9922c2SRobert Mustacchi.\" Copyright 2015 Joyent, Inc. 13fa9922c2SRobert Mustacchi.\" 14fa9922c2SRobert Mustacchi.Dd May 07, 2015 15fa9922c2SRobert Mustacchi.Dt AVL_FIRST 3AVL 16fa9922c2SRobert Mustacchi.Os 17fa9922c2SRobert Mustacchi.Sh NAME 18fa9922c2SRobert Mustacchi.Nm avl_first , 19fa9922c2SRobert Mustacchi.Nm AVL_NEXT , 20fa9922c2SRobert Mustacchi.Nm AVL_PREV , 21fa9922c2SRobert Mustacchi.Nm avl_last 22fa9922c2SRobert Mustacchi.Nd get the first, next, previous, and last entries from an AVL tree 23fa9922c2SRobert Mustacchi.Sh SYNOPSIS 24fa9922c2SRobert Mustacchi.Lb libavl 25fa9922c2SRobert Mustacchi.In sys/avl.h 26fa9922c2SRobert Mustacchi.Ft void * 27fa9922c2SRobert Mustacchi.Fo avl_first 28fa9922c2SRobert Mustacchi.Fa "avl_tree_t *tree" 29fa9922c2SRobert Mustacchi.Fc 30fa9922c2SRobert Mustacchi.Ft void * 31fa9922c2SRobert Mustacchi.Fo avl_last 32fa9922c2SRobert Mustacchi.Fa "avl_tree_t *tree" 33fa9922c2SRobert Mustacchi.Fc 34fa9922c2SRobert Mustacchi.Ft void * 35fa9922c2SRobert Mustacchi.Fo AVL_NEXT 36fa9922c2SRobert Mustacchi.Fa "avl_tree_t *tree" 37fa9922c2SRobert Mustacchi.Fa "void *node" 38fa9922c2SRobert Mustacchi.Fc 39fa9922c2SRobert Mustacchi.Ft void * 40fa9922c2SRobert Mustacchi.Fo AVL_PREV 41fa9922c2SRobert Mustacchi.Fa "avl_tree_t *tree" 42fa9922c2SRobert Mustacchi.Fa "void *node" 43fa9922c2SRobert Mustacchi.Fc 44fa9922c2SRobert Mustacchi.Sh DESCRIPTION 45fa9922c2SRobert MustacchiThe 46fa9922c2SRobert Mustacchi.Fn avl_first 47fa9922c2SRobert Mustacchiand 48fa9922c2SRobert Mustacchi.Fn avl_last 49fa9922c2SRobert Mustacchirespectively return the first and last entry in the tree specified by 50fa9922c2SRobert Mustacchi.Fa tree . 51fa9922c2SRobert MustacchiOrder in the tree is determined by the comparison function that was 52fa9922c2SRobert Mustacchispecified at the time the tree was created with 53fa9922c2SRobert Mustacchi.Xr avl_create 3AVL . 54fa9922c2SRobert MustacchiIf 55fa9922c2SRobert Mustacchi.Fa tree 56fa9922c2SRobert Mustacchiis empty, then 57fa9922c2SRobert Mustacchi.Fn avl_first 58fa9922c2SRobert Mustacchiand 59fa9922c2SRobert Mustacchi.Fn avl_last 60fa9922c2SRobert Mustacchireturn 61fa9922c2SRobert Mustacchi.Sy NULL . 62fa9922c2SRobert Mustacchi.Pp 63fa9922c2SRobert MustacchiThe 64fa9922c2SRobert Mustacchi.Fn AVL_NEXT 65fa9922c2SRobert Mustacchiand 66fa9922c2SRobert Mustacchi.Fn AVL_PREV 67fa9922c2SRobert Mustacchifunctions are macros that may be used to obtain the next and previous 68fa9922c2SRobert Mustacchientry following 69fa9922c2SRobert Mustacchi.Fa node 70fa9922c2SRobert Mustacchiin the AVL tree 71fa9922c2SRobert Mustacchi.Fa tree . 72fa9922c2SRobert MustacchiIf there is no next or previous node, for example, if one was at the 73fa9922c2SRobert Mustacchibeginning or end of the tree, then 74fa9922c2SRobert Mustacchi.Sy NULL 75fa9922c2SRobert Mustacchiis returned. 76fa9922c2SRobert Mustacchi.Pp 77fa9922c2SRobert MustacchiThese constructs are generally used as part of loops to iterate the 78fa9922c2SRobert Mustacchitree. See the examples section in 79fa9922c2SRobert Mustacchi.Xr libavl 3LIB 80fa9922c2SRobert Mustacchifor more information on using this 81fa9922c2SRobert Mustacchiinterface. 82fa9922c2SRobert Mustacchi.Sh RETURN VALUES 83fa9922c2SRobert MustacchiThe 84fa9922c2SRobert Mustacchi.Fn avl_first 85fa9922c2SRobert Mustacchifunction returns a pointer to the first entry in the AVL tree 86fa9922c2SRobert Mustacchi.Fa tree 87fa9922c2SRobert Mustacchior 88fa9922c2SRobert Mustacchi.Sy NULL 89fa9922c2SRobert Mustacchiif the AVL tree is empty. 90fa9922c2SRobert Mustacchi.Pp 91fa9922c2SRobert MustacchiThe 92fa9922c2SRobert Mustacchi.Fn avl_last 93fa9922c2SRobert Mustacchifunction returns a pointer to the last entry in the AVL tree 94fa9922c2SRobert Mustacchi.Fa tree 95fa9922c2SRobert Mustacchior 96fa9922c2SRobert Mustacchi.Sy NULL 97fa9922c2SRobert Mustacchiif the AVL tree is empty. 98fa9922c2SRobert Mustacchi.Pp 99fa9922c2SRobert MustacchiThe 100fa9922c2SRobert Mustacchi.Fn AVL_NEXT 101fa9922c2SRobert Mustacchimacro returns a pointer to the object in the tree that follows 102fa9922c2SRobert Mustacchi.Fa node . 103fa9922c2SRobert MustacchiIf 104fa9922c2SRobert Mustacchi.Fa node 105fa9922c2SRobert Mustacchiis the last entry in the tree, 106fa9922c2SRobert Mustacchi.Sy NULL 107fa9922c2SRobert Mustacchiis returned instead. 108fa9922c2SRobert Mustacchi.Pp 109fa9922c2SRobert MustacchiThe 110fa9922c2SRobert Mustacchi.Fn AVL_PREV 111fa9922c2SRobert Mustacchimacro returns a pointer to the object in the tree that precedes 112fa9922c2SRobert Mustacchi.Fa node . 113fa9922c2SRobert MustacchiIf 114fa9922c2SRobert Mustacchi.Fa node 115fa9922c2SRobert Mustacchiis the first entry in the tree, 116fa9922c2SRobert Mustacchi.Sy NULL 117fa9922c2SRobert Mustacchiis returned instead. 118fa9922c2SRobert Mustacchi.Sh EXAMPLES 119fa9922c2SRobert MustacchiSee the 120fa9922c2SRobert Mustacchi.Sy EXAMPLES 121fa9922c2SRobert Mustacchisection in 122fa9922c2SRobert Mustacchi.Xr libavl 3LIB . 123fa9922c2SRobert Mustacchi.Sh INTERFACE STABILITY 124fa9922c2SRobert Mustacchi.Sy Committed 125fa9922c2SRobert Mustacchi.Sh MT-Level 126fa9922c2SRobert MustacchiSee 127fa9922c2SRobert Mustacchi.Sx Locking 128fa9922c2SRobert Mustacchiin 129fa9922c2SRobert Mustacchi.Xr libavl 3LIB . 130fa9922c2SRobert Mustacchi.Sh SEE ALSO 131*3a005aadSYuri Pankov.Xr avl_create 3AVL , 132*3a005aadSYuri Pankov.Xr libavl 3LIB 133