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
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.
12 .\" Copyright 2015 Joyent, Inc.
19 .Nd create an AVL tree
25 .Fa "avl_tree_t *tree"
26 .Fa "int (*compare)(const void *first, const void *second)"
33 function initializes an AVL tree rooted at
36 An AVL tree needs to encode information about the type of data
37 structures being stored inside of it and needs to be told how to compare
38 two different entries in the same tree.
41 argument represents the total size of the data structure being used in
43 This is a constant that is generally expressed to
49 The data structure that is being stored in the AVL tree must include an
51 as a member of the structure.
52 The structure may have multiple
54 one for each AVL tree that it may concurrently be a member of.
57 argument indicates what the offset of the
59 is for the data structure that this AVL tree contains.
63 function pointer is used to compare two nodes in the tree.
64 This is used as part of all operations on the tree that cause traversal.
65 The function is given, as arguments, two pointers to the actual data nodes,
66 which should be cast to the corresponding type of actual data.
67 The return value must adhere to the following rules:
70 If the first argument,
72 is less than the second argument,
79 If the first argument is greater than the second argument, then the
84 Otherwise, if they compare to the same value, then it should return
87 Only the return values, -1, 0, and 1, are valid.
88 Returning values other than those will result in undefined behavior.
91 When two nodes in the tree compare equal, then that means that they
92 should represent the same data, though they may not always be equivalent
93 pointers, due to lookups.
95 The life time and storage of the AVL tree is maintained by the caller.
96 The library does not perform any allocations as part of creating an AVL
103 .Sh INTERFACE STABILITY