1 --- tsearch.3.orig 2007-03-06 15:44:54.000000000 -0800
2 +++ tsearch.3 2007-03-06 16:04:48.000000000 -0800
7 -.Nm tsearch , tfind , tdelete , twalk
12 .Nd manipulate binary search trees
16 -.Fn tdelete "const void * restrict key" "void ** restrict rootp" "int (*compar) (const void *, const void *)"
18 +.Fa "const void *restrict key"
19 +.Fa "void **restrict rootp"
20 +.Fa "int (*compar) (const void *key1, const void *key2)"
23 -.Fn tfind "const void *key" "void * const *rootp" "int (*compar) (const void *, const void *)"
25 +.Fa "const void *key"
26 +.Fa "void *const *rootp"
27 +.Fa "int (*compar) (const void *key1, const void *key2)"
30 -.Fn tsearch "const void *key" "void **rootp" "int (*compar) (const void *, const void *)"
32 +.Fa "const void *key"
34 +.Fa "int (*compar) (const void *key1, const void *key2)"
37 -.Fn twalk "const void *root" "void (*compar) (const void *, VISIT, int)"
39 +.Fa "const void *root"
40 +.Fa "void (*compar) (const void *node, VISIT order, int level)"
49 -functions manage binary search trees based on algorithms T and D
50 +functions manage binary search trees, based on algorithms T and D
52 The comparison function passed in by
53 -the user has the same style of return values as
54 +the user takes two arguments, each of which is a key
56 +This function has the same style of return values as
62 -searches for the datum matched by the argument
63 +searches for a node whose key matches the argument
65 in the binary tree rooted at
67 -returning a pointer to the datum if it is found and NULL
68 +returning a pointer to the node if it is found and NULL
71 +Note that a node is itself a pointer to the key of the node.
72 +Thus, you should generally cast this result to a
73 +double pointer to the data type stored in the tree, for example
74 +(struct myType **), and use double indirection to retrieve the
81 +function is identical to
83 -except that if no match is found,
84 +except that, if no match is found,
85 +it inserts a new node for the
87 -is inserted into the tree and a pointer to it is returned.
88 +into the tree and returns a pointer to the node.
91 -points to a NULL value a new binary search tree is created.
92 +points to a NULL value, a new binary search tree is created.
97 -deletes a node from the specified binary search tree and returns
98 -a pointer to the parent of the node to be deleted.
99 +function deletes a node from the specified binary search tree
100 +and returns a pointer to the parent of the node that was deleted.
101 It takes the same arguments as
109 -walks the binary search tree rooted in
110 +function walks the binary search tree rooted in
112 and calls the function
118 -is called with three arguments: a pointer to the current node,
119 +function is called with three arguments: a pointer to the current node,
120 a value from the enum
121 .Sy "typedef enum { preorder, postorder, endorder, leaf } VISIT;"
122 specifying the traversal type, and a node level (where level
123 zero is the root of the tree).
127 +traverses the tree, it calls the
129 +function with the traversal type "preorder"
130 +before visiting the left subtree of the
133 +traversal type "postorder" before visiting the right subtree
136 +and with the traversal type "endorder" after
137 +visiting the right subtree of the
142 +function is called only once for a leaf-node, with the
143 +traversal type "leaf."
145 +Note: the names for the traversal types differ somewhat from
146 +common parlance. The traversal type "postorder" corresponds
147 +to what would typically be referred to as in-order, and the
148 +traversal type "endorder" corresponds to what would typically
149 +be referred to as post-order.
157 -is NULL or the datum cannot be found.
158 +is NULL or the node cannot be found.