|
@ -23,7 +23,7 @@ |
|
|
.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
|
|
.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
|
|
.\" ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
|
.\" ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
|
.\" |
|
|
.\" |
|
|
.\" $OpenBSD: tsearch.3,v 1.2 1998/06/21 22:13:49 millert Exp $ |
|
|
|
|
|
|
|
|
.\" $OpenBSD: tsearch.3,v 1.3 1999/02/27 21:56:03 deraadt Exp $ |
|
|
.\" |
|
|
.\" |
|
|
.Dd June 15, 1997 |
|
|
.Dd June 15, 1997 |
|
|
.Dt TSEARCH 3 |
|
|
.Dt TSEARCH 3 |
|
@ -53,7 +53,7 @@ from Knuth (6.2.2). The comparison function passed in by |
|
|
the user has the same style of return values as |
|
|
the user has the same style of return values as |
|
|
.Xr strcmp 3 . |
|
|
.Xr strcmp 3 . |
|
|
.Pp |
|
|
.Pp |
|
|
.Fn Tfind |
|
|
|
|
|
|
|
|
.Fn tfind |
|
|
searches for the datum matched by the argument |
|
|
searches for the datum matched by the argument |
|
|
.Fa key |
|
|
.Fa key |
|
|
in the binary tree rooted at |
|
|
in the binary tree rooted at |
|
@ -61,7 +61,7 @@ in the binary tree rooted at |
|
|
returning a pointer to the datum if it is found and NULL |
|
|
returning a pointer to the datum if it is found and NULL |
|
|
if it is not. |
|
|
if it is not. |
|
|
.Pp |
|
|
.Pp |
|
|
.Fn Tsearch |
|
|
|
|
|
|
|
|
.Fn tsearch |
|
|
is identical to |
|
|
is identical to |
|
|
.Fn tfind |
|
|
.Fn tfind |
|
|
except that if no match is found, |
|
|
except that if no match is found, |
|
@ -70,7 +70,7 @@ is inserted into the tree and a pointer to it is returned. If |
|
|
.Fa rootp |
|
|
.Fa rootp |
|
|
points to a NULL value a new binary search tree is created. |
|
|
points to a NULL value a new binary search tree is created. |
|
|
.Pp |
|
|
.Pp |
|
|
.Fn Tdelete |
|
|
|
|
|
|
|
|
.Fn tdelete |
|
|
deletes a node from the specified binary search tree and returns |
|
|
deletes a node from the specified binary search tree and returns |
|
|
a pointer to the parent of the node to be deleted. |
|
|
a pointer to the parent of the node to be deleted. |
|
|
It takes the same arguments as |
|
|
It takes the same arguments as |
|
@ -81,13 +81,13 @@ If the node to be deleted is the root of the binary search tree, |
|
|
.Fa rootp |
|
|
.Fa rootp |
|
|
will be adjusted. |
|
|
will be adjusted. |
|
|
.Pp |
|
|
.Pp |
|
|
.Fn Twalk |
|
|
|
|
|
|
|
|
.Fn twalk |
|
|
walks the binary search tree rooted in |
|
|
walks the binary search tree rooted in |
|
|
.fa root |
|
|
.fa root |
|
|
and calls the function |
|
|
and calls the function |
|
|
.Fa action |
|
|
.Fa action |
|
|
on each node. |
|
|
on each node. |
|
|
.Fa Action |
|
|
|
|
|
|
|
|
.Fa action |
|
|
is called with three arguments: a pointer to the current node, |
|
|
is called with three arguments: a pointer to the current node, |
|
|
a value from the enum |
|
|
a value from the enum |
|
|
.Sy "typedef enum { preorder, postorder, endorder, leaf } VISIT;" |
|
|
.Sy "typedef enum { preorder, postorder, endorder, leaf } VISIT;" |
|
@ -103,7 +103,7 @@ The |
|
|
function returns NULL if allocation of a new node fails (usually |
|
|
function returns NULL if allocation of a new node fails (usually |
|
|
due to a lack of free memory). |
|
|
due to a lack of free memory). |
|
|
.Pp |
|
|
.Pp |
|
|
.Fn Tfind , |
|
|
|
|
|
|
|
|
.Fn tfind , |
|
|
.Fn tsearch , |
|
|
.Fn tsearch , |
|
|
and |
|
|
and |
|
|
.Fn tdelete |
|
|
.Fn tdelete |
|
|