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