diff options
Diffstat (limited to 'src/lib/libc/stdlib/tsearch.3')
-rw-r--r-- | src/lib/libc/stdlib/tsearch.3 | 126 |
1 files changed, 0 insertions, 126 deletions
diff --git a/src/lib/libc/stdlib/tsearch.3 b/src/lib/libc/stdlib/tsearch.3 deleted file mode 100644 index a7ab985013..0000000000 --- a/src/lib/libc/stdlib/tsearch.3 +++ /dev/null | |||
@@ -1,126 +0,0 @@ | |||
1 | .\" $OpenBSD: tsearch.3,v 1.22 2022/03/31 17:27:16 naddy Exp $ | ||
2 | .\" | ||
3 | .\" Copyright (c) 1997 Todd C. Miller <millert@openbsd.org> | ||
4 | .\" | ||
5 | .\" Permission to use, copy, modify, and distribute this software for any | ||
6 | .\" purpose with or without fee is hereby granted, provided that the above | ||
7 | .\" copyright notice and this permission notice appear in all copies. | ||
8 | .\" | ||
9 | .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
10 | .\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
11 | .\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
12 | .\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
13 | .\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
14 | .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
15 | .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
16 | .\" | ||
17 | .Dd $Mdocdate: March 31 2022 $ | ||
18 | .Dt TSEARCH 3 | ||
19 | .Os | ||
20 | .Sh NAME | ||
21 | .Nm tsearch , | ||
22 | .Nm tfind , | ||
23 | .Nm tdelete , | ||
24 | .Nm twalk | ||
25 | .Nd manipulate binary search trees | ||
26 | .Sh SYNOPSIS | ||
27 | .In search.h | ||
28 | .Ft void * | ||
29 | .Fn tdelete "const void *key" "void **rootp" "int (*compar)(const void *, const void *)" | ||
30 | .Ft void * | ||
31 | .Fn tfind "const void *key" "void * const *rootp" "int (*compar)(const void *, const void *)" | ||
32 | .Ft void * | ||
33 | .Fn tsearch "const void *key" "void **rootp" "int (*compar)(const void *, const void *)" | ||
34 | .Ft void | ||
35 | .Fn twalk "const void *root" "void (*action)(const void *, VISIT, int)" | ||
36 | .Sh DESCRIPTION | ||
37 | The | ||
38 | .Fn tdelete , | ||
39 | .Fn tfind , | ||
40 | .Fn tsearch , | ||
41 | and | ||
42 | .Fn twalk | ||
43 | functions manage binary search trees based on algorithms T and D | ||
44 | from Knuth (6.2.2). | ||
45 | The comparison function passed in by | ||
46 | the user has the same style of return values as | ||
47 | .Xr strcmp 3 . | ||
48 | .Pp | ||
49 | .Fn tfind | ||
50 | searches for the datum matched by the argument | ||
51 | .Fa key | ||
52 | in the binary tree rooted at | ||
53 | .Fa rootp , | ||
54 | returning a pointer to the datum if it is found and | ||
55 | .Dv NULL | ||
56 | if it is not. | ||
57 | .Pp | ||
58 | .Fn tsearch | ||
59 | is identical to | ||
60 | .Fn tfind | ||
61 | except that if no match is found, | ||
62 | .Fa key | ||
63 | is inserted into the tree and a pointer to it is returned. | ||
64 | If | ||
65 | .Fa rootp | ||
66 | points to a null value, a new binary search tree is created. | ||
67 | .Pp | ||
68 | .Fn tdelete | ||
69 | deletes a node from the specified binary search tree and returns | ||
70 | a pointer to the parent of the node to be deleted. | ||
71 | If the node to be deleted is the root of the binary search tree, | ||
72 | .Fa rootp | ||
73 | will be adjusted and an unspecified non-null pointer will be returned. | ||
74 | It takes the same arguments as | ||
75 | .Fn tfind | ||
76 | and | ||
77 | .Fn tsearch . | ||
78 | .Pp | ||
79 | .Fn twalk | ||
80 | walks the binary search tree rooted in | ||
81 | .Fa root | ||
82 | and calls the function | ||
83 | .Fa action | ||
84 | on each node. | ||
85 | .Fa action | ||
86 | is called with three arguments: a pointer to the current node, | ||
87 | a value from the enum | ||
88 | .Sy "typedef enum { preorder, postorder, endorder, leaf } VISIT;" | ||
89 | specifying the traversal type, and a node level (where level | ||
90 | zero is the root of the tree). | ||
91 | .Sh RETURN VALUES | ||
92 | The | ||
93 | .Fn tsearch | ||
94 | function returns | ||
95 | .Dv NULL | ||
96 | if allocation of a new node fails (usually | ||
97 | due to a lack of free memory). | ||
98 | .Pp | ||
99 | .Fn tdelete | ||
100 | returns a pointer to the parent of the deleted node or an unspecified | ||
101 | non-null pointer if the root node is deleted. | ||
102 | .Pp | ||
103 | .Fn tfind , | ||
104 | .Fn tsearch , | ||
105 | and | ||
106 | .Fn tdelete | ||
107 | return | ||
108 | .Dv NULL | ||
109 | if | ||
110 | .Fa rootp | ||
111 | is | ||
112 | .Dv NULL | ||
113 | or the datum cannot be found. | ||
114 | .Sh SEE ALSO | ||
115 | .Xr bsearch 3 , | ||
116 | .Xr lsearch 3 | ||
117 | .Sh STANDARDS | ||
118 | These functions conform to | ||
119 | .St -p1003.1-2008 . | ||
120 | .Sh CAVEATS | ||
121 | The value returned when deleting the root node was unspecified before | ||
122 | the | ||
123 | .St -p1003.1-2008 | ||
124 | standard, so users of the | ||
125 | .Fn tdelete | ||
126 | function should be wary of relying on a specific behaviour. | ||