xref: /titanic_41/usr/src/man/man3avl/avl_add.3avl (revision d9fc8ba670791dc3b8398347e67e1c5825d5e341)
1.\"
2.\" This file and its contents are supplied under the terms of the
3.\" Common Development and Distribution License ("CDDL"), version 1.0.
4.\" You may only use this file in accordance with the terms of version
5.\" 1.0 of the CDDL.
6.\"
7.\" A full copy of the text of the CDDL should have accompanied this
8.\" source.  A copy of the CDDL is also available via the Internet at
9.\" http://www.illumos.org/license/CDDL.
10.\"
11.\"
12.\" Copyright 2015 Joyent, Inc.
13.\"
14.Dd Apr 13, 2015
15.Dt AVL_ADD 3AVL
16.Os
17.Sh NAME
18.Nm avl_add ,
19.Nm avl_remove
20.Nd add and remove nodes from an AVL tree
21.Sh SYNOPSIS
22.Lb libavl
23.In sys/avl.h
24.Ft void
25.Fo avl_add
26.Fa "avl_tree_t *tree"
27.Fa "void *node"
28.Fc
29.Ft void
30.Fo avl_remove
31.Fa "avl_tree_t *tree"
32.Fa "void *node"
33.Fc
34.Sh DESCRIPTION
35The
36.Fn avl_add
37and
38.Fn avl_remove
39functions add and remove objects from the AVL tree rooted at
40.Fa tree .
41.Pp
42The
43.Fn avl_add
44function inserts
45.Fa node
46into the tree.
47.Fa node
48must not already be in the tree, thus implying it must not compare equal
49to any other node in the tree. Adding
50.Fa node
51to
52.Fa tree
53will take
54.Sy O(log(n))
55time, as it implicitly determines where to place it in the tree.
56If
57.Fa node Ns 's
58location has already been determined by
59.Xr avl_find 3AVL ,
60then instead use
61.Xr avl_insert 3AVL .
62.Pp
63The
64.Fn avl_remove
65function removes
66.Fa node
67from the tree rooted at
68.Fa tree .
69.Fa node
70must be present in the tree, otherwise, the behavior is undefined.
71Deleting
72.Fa node
73from
74.Fa tree
75occurs in
76.Sy O(log(n))
77time.
78.Sh EXAMPLES
79See the
80.Sy EXAMPLES
81section in
82.Xr libavl 3LIB .
83.Sh INTERFACE STABILITY
84.Sy Committed
85.Sh MT-Level
86See
87.Sx Locking
88in
89.Xr libavl 3LIB .
90.Sh SEE ALSO
91.Xr libavl 3LIB ,
92.Xr avl_create 3AVL ,
93.Xr avl_insert 3AVL ,
94.Xr avl_insert_here 3AVL ,
95.Xr avl_destroy 3AVL
96