Document RB_FOREACH_SAFE() and RB_FOREACH_REVERSE_SAFE().
Submitted by: Mikhail <mp lenta.ru>
This commit is contained in:
parent
2f2f23894e
commit
9dbae282ea
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=257643
@ -30,7 +30,7 @@
|
|||||||
.\"
|
.\"
|
||||||
.\" $FreeBSD$
|
.\" $FreeBSD$
|
||||||
.\"
|
.\"
|
||||||
.Dd December 27, 2007
|
.Dd November 4, 2013
|
||||||
.Dt TREE 3
|
.Dt TREE 3
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
@ -70,7 +70,9 @@
|
|||||||
.Nm RB_RIGHT ,
|
.Nm RB_RIGHT ,
|
||||||
.Nm RB_PARENT ,
|
.Nm RB_PARENT ,
|
||||||
.Nm RB_FOREACH ,
|
.Nm RB_FOREACH ,
|
||||||
|
.Nm RB_FOREACH_SAFE ,
|
||||||
.Nm RB_FOREACH_REVERSE ,
|
.Nm RB_FOREACH_REVERSE ,
|
||||||
|
.Nm RB_FOREACH_REVERSE_SAFE ,
|
||||||
.Nm RB_INIT ,
|
.Nm RB_INIT ,
|
||||||
.Nm RB_INSERT ,
|
.Nm RB_INSERT ,
|
||||||
.Nm RB_REMOVE
|
.Nm RB_REMOVE
|
||||||
@ -135,7 +137,9 @@
|
|||||||
.Ft "struct TYPE *"
|
.Ft "struct TYPE *"
|
||||||
.Fn RB_PARENT "struct TYPE *elm" "RB_ENTRY NAME"
|
.Fn RB_PARENT "struct TYPE *elm" "RB_ENTRY NAME"
|
||||||
.Fn RB_FOREACH VARNAME NAME "RB_HEAD *head"
|
.Fn RB_FOREACH VARNAME NAME "RB_HEAD *head"
|
||||||
|
.Fn RB_FOREACH_SAFE "VARNAME" "NAME" "RB_HEAD *head" "TEMP_VARNAME"
|
||||||
.Fn RB_FOREACH_REVERSE VARNAME NAME "RB_HEAD *head"
|
.Fn RB_FOREACH_REVERSE VARNAME NAME "RB_HEAD *head"
|
||||||
|
.Fn RB_FOREACH_REVERSE_SAFE "VARNAME" "NAME" "RB_HEAD *head" "TEMP_VARNAME"
|
||||||
.Ft void
|
.Ft void
|
||||||
.Fn RB_INIT "RB_HEAD *head"
|
.Fn RB_INIT "RB_HEAD *head"
|
||||||
.Ft "struct TYPE *"
|
.Ft "struct TYPE *"
|
||||||
@ -454,6 +458,18 @@ macro:
|
|||||||
.Fn RB_FOREACH np NAME head
|
.Fn RB_FOREACH np NAME head
|
||||||
.Ed
|
.Ed
|
||||||
.Pp
|
.Pp
|
||||||
|
The macros
|
||||||
|
.Fn RB_FOREACH_SAFE
|
||||||
|
and
|
||||||
|
.Fn RB_FOREACH_REVERSE_SAFE
|
||||||
|
traverse the tree referenced by head
|
||||||
|
in a forward or reverse direction respectively,
|
||||||
|
assigning each element in turn to np.
|
||||||
|
However, unlike their unsafe counterparts,
|
||||||
|
they permit both the removal of np
|
||||||
|
as well as freeing it from within the loop safely
|
||||||
|
without interfering with the traversal.
|
||||||
|
.Pp
|
||||||
The
|
The
|
||||||
.Fn RB_EMPTY
|
.Fn RB_EMPTY
|
||||||
macro should be used to check whether a red-black tree is empty.
|
macro should be used to check whether a red-black tree is empty.
|
||||||
|
Loading…
Reference in New Issue
Block a user