summaryrefslogtreecommitdiff
path: root/share/man/man3
diff options
context:
space:
mode:
authorMike Frantzen <frantzen@cvs.openbsd.org>2002-03-25 21:53:40 +0000
committerMike Frantzen <frantzen@cvs.openbsd.org>2002-03-25 21:53:40 +0000
commit1004f5733a9c92f16ca07bfe7ba3b3fb5f6386f7 (patch)
tree9043c1b3fd49d0ea85183179be01c39991f496ee /share/man/man3
parent39c3b1afe430e2e854e0429399b417c3905b2c4f (diff)
document the {SPLAY,RB}_INITIALIZER and {SPLAY,RB}_EMPTY() macros
Diffstat (limited to 'share/man/man3')
-rw-r--r--share/man/man3/Makefile8
-rw-r--r--share/man/man3/tree.334
2 files changed, 38 insertions, 4 deletions
diff --git a/share/man/man3/Makefile b/share/man/man3/Makefile
index 9455adbf345..13496b47a5a 100644
--- a/share/man/man3/Makefile
+++ b/share/man/man3/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.12 2002/02/24 19:49:17 provos Exp $
+# $OpenBSD: Makefile,v 1.13 2002/03/25 21:53:39 frantzen Exp $
# @(#)Makefile 8.2 (Berkeley) 12/13/93
MAN= assert.3 bitstring.3 dlfcn.3 end.3 intro.3 queue.3 stdarg.3 \
@@ -50,14 +50,16 @@ MLINKS+=dlfcn.3 dlopen.3 dlfcn.3 dlclose.3 dlfcn.3 dlsym.3 dlfcn.3 dlctl.3 \
dlfcn.3 dlerror.3
MLINKS+=tree.3 SPLAY_PROTOTYPE.3 tree.3 SPLAY_GENERATE.3 \
tree.3 SPLAY_ENTRY.3 tree.3 SPLAY_HEAD.3 \
- tree.3 SPLAY_ROOT.3 tree.3 SPLAY_NEXT.3 \
+ tree.3 SPLAY_INITIALIZER.3 tree.3 SPLAY_ROOT.3 \
+ tree.3 SPLAY_EMPTY.3 tree.3 SPLAY_NEXT.3 \
tree.3 SPLAY_MIN.3 tree.3 SPLAY_MAX.3 tree.3 SPLAY_FIND.3 \
tree.3 SPLAY_LEFT.3 tree.3 SPLAY_RIGHT.3 tree.3 SPLAY_INIT.3 \
tree.3 SPLAY_INSERT.3 tree.3 SPLAY_REMOVE.3 \
tree.3 SPLAY_FOREACH.3
MLINKS+=tree.3 RB_PROTOTYPE.3 tree.3 RB_GENERATE.3 \
tree.3 RB_ENTRY.3 tree.3 RB_HEAD.3 \
- tree.3 RB_ROOT.3 tree.3 RB_NEXT.3 \
+ tree.3 RB_INITIALIZER.3 tree.3 RB_ROOT.3 \
+ tree.3 RB_EMPTY.3 tree.3 RB_NEXT.3 \
tree.3 RB_MIN.3 tree.3 RB_MAX.3 tree.3 RB_FIND.3 \
tree.3 RB_LEFT.3 tree.3 RB_RIGHT.3 tree.3 RB_PARENT.3 \
tree.3 RB_INIT.3 tree.3 RB_INSERT.3 tree.3 RB_REMOVE.3 \
diff --git a/share/man/man3/tree.3 b/share/man/man3/tree.3
index cda712670c8..ace2a07cbed 100644
--- a/share/man/man3/tree.3
+++ b/share/man/man3/tree.3
@@ -1,4 +1,4 @@
-.\" $OpenBSD: tree.3,v 1.2 2002/03/19 00:07:45 vincent Exp $
+.\" $OpenBSD: tree.3,v 1.3 2002/03/25 21:53:39 frantzen Exp $
.\"/*
.\" * Copyright 2002 Niels Provos <provos@citi.umich.edu>
.\" * All rights reserved.
@@ -36,7 +36,9 @@
.Nm SPLAY_GENERATE,
.Nm SPLAY_ENTRY ,
.Nm SPLAY_HEAD ,
+.Nm SPLAY_INITIALIZER ,
.Nm SPLAY_ROOT ,
+.Nm SPLAY_EMPTY ,
.Nm SPLAY_NEXT ,
.Nm SPLAY_MIN ,
.Nm SPLAY_MAX ,
@@ -51,7 +53,9 @@
.Nm RB_GENERATE,
.Nm RB_ENTRY ,
.Nm RB_HEAD ,
+.Nm RB_INITIALIZER ,
.Nm RB_ROOT ,
+.Nm RB_EMPTY ,
.Nm RB_NEXT ,
.Nm RB_MIN ,
.Nm RB_MAX ,
@@ -72,7 +76,10 @@
.Fn SPLAY_ENTRY "TYPE"
.Fn SPLAY_HEAD "HEADNAME" "TYPE"
.Ft "struct TYPE *"
+.Fn SPLAY_INITIALIZER "SPLAY_HEAD *head"
.Fn SPLAY_ROOT "SPLAY_HEAD *head"
+.Ft "bool"
+.Fn SPLAY_EMPTY "SPLAY_HEAD *head"
.Ft "struct TYPE *"
.Fn SPLAY_NEXT "NAME" "SPLAY_HEAD *head" "struct TYPE *elm"
.Ft "struct TYPE *"
@@ -97,8 +104,11 @@
.Fn RB_GENERATE "NAME" "TYPE" "FIELD" "CMP"
.Fn RB_ENTRY "TYPE"
.Fn RB_HEAD "HEADNAME" "TYPE"
+.Fn RB_INITIALIZER "RB_HEAD *head"
.Ft "struct TYPE *"
.Fn RB_ROOT "RB_HEAD *head"
+.Ft "bool"
+.Fn RB_EMPTY "RB_HEAD *head"
.Ft "struct TYPE *"
.Fn RB_NEXT "NAME" "RB_HEAD *head" "struct TYPE *elm"
.Ft "struct TYPE *"
@@ -223,6 +233,13 @@ The
macro initializes the tree referenced by
.Fa head .
.Pp
+The splay tree can also be initialized statically by using the
+.Fn SPLAY_INITIALIZER
+macro like this:
+.Bd -literal -offset indent
+SPLAY_HEAD(HEADNAME, TYPE) head = SPLAY_INITIALIZER(&head);
+.Ed
+.Pp
The
.Fn SPLAY_INSERT
macro inserts the new element
@@ -263,6 +280,10 @@ macro:
SPLAY_FOREACH(np, NAME, head)
.Ed
.Pp
+The
+.Fn SPLAY_EMPTY
+macro should be used to check whether a splay tree is empty.
+.Pp
.Sh RED-BLACK TREES
A red-black tree is a binary search tree with the node color as an
extra attribute. It fulfills a set of conditions:
@@ -337,6 +358,13 @@ The
macro initializes the tree referenced by
.Fa head .
.Pp
+The redblack tree can also be initialized statically by using the
+.Fn RB_INITIALIZER
+macro like this:
+.Bd -literal -offset indent
+RB_HEAD(HEADNAME, TYPE) head = RB_INITIALIZER(&head);
+.Ed
+.Pp
The
.Fn RB_INSERT
macro inserts the new element
@@ -377,6 +405,10 @@ macro:
RB_FOREACH(np, NAME, head)
.Ed
.Pp
+The
+.Fn RB_EMPTY
+macro should be used to check whether a splay tree is empty.
+.Pp
.Sh NOTES
Trying to free a tree in the following way is a common error:
.Bd -literal -offset indent