Page MenuHomeFreeBSD

Add a complete example to tsearch(3)
ClosedPublic

Authored by brd on Jun 5 2017, 5:07 AM.
Tags
None
Referenced Files
F80232810: D11053.id30793.diff
Fri, Mar 29, 12:57 PM
Unknown Object (File)
Dec 20 2023, 5:23 AM
Unknown Object (File)
Jun 20 2023, 5:53 PM
Unknown Object (File)
Jun 14 2023, 4:44 AM
Unknown Object (File)
May 2 2023, 9:11 AM
Unknown Object (File)
Mar 8 2023, 1:53 AM
Unknown Object (File)
Feb 9 2023, 11:39 PM
Unknown Object (File)
Jan 29 2023, 2:41 PM
Subscribers

Details

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

sevan added inline comments.
head/lib/libc/stdlib/tsearch.3
134

"each one of them against each other"?

135

"by adding them to the tree and attempting"?

136

s/uses/using?

brueffer added inline comments.
head/lib/libc/stdlib/tsearch.3
136

.Fn tfind (see the .Fn twalk just above the EXAMPLES section); same for tdelete.

137

Please start a new sentence on a new line; ".Fn twalk" (same as above).

brd marked 5 inline comments as done.

Address feedback

head/lib/libc/stdlib/tsearch.3
134–140

I find the paragraph to be quite difficult to parse in one pass.
Just a suggestion but It may be better to break it up rather than using more than one conjunction to say it as one.

"The following example takes in four strings and compares each one of them against each other before adding them to the tree. The fourth string is added a second time. tfind is used to verify that a duplicate is not added and tdelete is used to remove it"

question, is the it on the end of the sentence referring to a duplicate or any entry that's been added?

head/lib/libc/stdlib/tsearch.3
134–140

I agree with sevan, I've had problems understanding that paragraph (refrained from commenting since he already had :-). The suggested re-wording sounds like an improvement. The rest looks good!

head/lib/libc/stdlib/tsearch.3
134–140

Hm. The example code is... not overly clear. But maybe this describes it?

This example uses
.Fn tsearch
to search for four strings in
.Dv root .
Because the strings are not already present, they are added.
.Fn tsearch
is called twice on the fourth string to demonstrate that a string is not added when it is already present.
.Fn tfind
is used to find the single instance of the fourth string, and
.Fn tdelete
removes it.
Finally,
.Fn twalk
is used to return and display the resulting binary search tree.

Thanks @wblock! That is much better!

brd marked 3 inline comments as done.Jul 13 2017, 9:15 PM

Thank you. Please check with igor and mandoc -Tlint before commit.

This revision is now accepted and ready to land.Jul 14 2017, 4:00 PM
This revision was automatically updated to reflect the committed changes.