update to add LIST_INSERT_BEFORE and TAILQ_INSERT_BEFORE
authorKirk McKusick <mckusick@ucbvax.Berkeley.EDU>
Sun, 21 Aug 1994 06:44:11 +0000 (22:44 -0800)
committerKirk McKusick <mckusick@ucbvax.Berkeley.EDU>
Sun, 21 Aug 1994 06:44:11 +0000 (22:44 -0800)
SCCS-vsn: share/man/man3/queue.3 8.3

usr/src/share/man/man3/queue.3

index d54702d..2829f00 100644 (file)
@@ -3,7 +3,7 @@
 .\"
 .\" %sccs.include.redist.roff%
 .\"
 .\"
 .\" %sccs.include.redist.roff%
 .\"
-.\"    @(#)queue.3     8.2 (Berkeley) %G%
+.\"    @(#)queue.3     8.3 (Berkeley) %G%
 .\"
 .Dd ""
 .Dt QUEUE 3
 .\"
 .Dd ""
 .Dt QUEUE 3
 .Nm LIST_HEAD ,
 .Nm LIST_INIT ,
 .Nm LIST_INSERT_AFTER ,
 .Nm LIST_HEAD ,
 .Nm LIST_INIT ,
 .Nm LIST_INSERT_AFTER ,
+.Nm LIST_INSERT_BEFORE ,
 .Nm LIST_INSERT_HEAD ,
 .Nm LIST_REMOVE ,
 .Nm TAILQ_ENTRY ,
 .Nm TAILQ_HEAD ,
 .Nm TAILQ_INIT ,
 .Nm TAILQ_INSERT_AFTER ,
 .Nm LIST_INSERT_HEAD ,
 .Nm LIST_REMOVE ,
 .Nm TAILQ_ENTRY ,
 .Nm TAILQ_HEAD ,
 .Nm TAILQ_INIT ,
 .Nm TAILQ_INSERT_AFTER ,
+.Nm TAILQ_INSERT_BEFORE ,
 .Nm TAILQ_INSERT_HEAD ,
 .Nm TAILQ_INSERT_TAIL ,
 .Nm TAILQ_REMOVE ,
 .Nm TAILQ_INSERT_HEAD ,
 .Nm TAILQ_INSERT_TAIL ,
 .Nm TAILQ_REMOVE ,
@@ -38,6 +40,7 @@
 .Fn LIST_HEAD "HEADNAME" "TYPE"
 .Fn LIST_INIT "LIST_HEAD *head"
 .Fn LIST_INSERT_AFTER "LIST_ENTRY *listelm" "TYPE *elm" "LIST_ENTRY NAME"
 .Fn LIST_HEAD "HEADNAME" "TYPE"
 .Fn LIST_INIT "LIST_HEAD *head"
 .Fn LIST_INSERT_AFTER "LIST_ENTRY *listelm" "TYPE *elm" "LIST_ENTRY NAME"
+.Fn LIST_INSERT_BEFORE "LIST_ENTRY *listelm" "TYPE *elm" "LIST_ENTRY NAME"
 .Fn LIST_INSERT_HEAD "LIST_HEAD *head" "TYPE *elm" "LIST_ENTRY NAME"
 .Fn LIST_REMOVE "TYPE *elm" "LIST_ENTRY NAME"
 .sp
 .Fn LIST_INSERT_HEAD "LIST_HEAD *head" "TYPE *elm" "LIST_ENTRY NAME"
 .Fn LIST_REMOVE "TYPE *elm" "LIST_ENTRY NAME"
 .sp
@@ -45,6 +48,7 @@
 .Fn TAILQ_HEAD "HEADNAME" "TYPE"
 .Fn TAILQ_INIT "TAILQ_HEAD *head"
 .Fn TAILQ_INSERT_AFTER "TAILQ_HEAD *head" "TYPE *listelm" "TYPE *elm" "TAILQ_ENTRY NAME"
 .Fn TAILQ_HEAD "HEADNAME" "TYPE"
 .Fn TAILQ_INIT "TAILQ_HEAD *head"
 .Fn TAILQ_INSERT_AFTER "TAILQ_HEAD *head" "TYPE *listelm" "TYPE *elm" "TAILQ_ENTRY NAME"
+.Fn TAILQ_INSERT_BEFORE "TAILQ_HEAD *head" "TYPE *listelm" "TYPE *elm" "TAILQ_ENTRY NAME"
 .Fn TAILQ_INSERT_HEAD "TAILQ_HEAD *head" "TYPE *elm" "TAILQ_ENTRY NAME"
 .Fn TAILQ_INSERT_TAIL "TAILQ_HEAD *head" "TYPE *elm" "TAILQ_ENTRY NAME"
 .Fn TAILQ_REMOVE "TAILQ_HEAD *head" "TYPE *elm" "TAILQ_ENTRY NAME"
 .Fn TAILQ_INSERT_HEAD "TAILQ_HEAD *head" "TYPE *elm" "TAILQ_ENTRY NAME"
 .Fn TAILQ_INSERT_TAIL "TAILQ_HEAD *head" "TYPE *elm" "TAILQ_ENTRY NAME"
 .Fn TAILQ_REMOVE "TAILQ_HEAD *head" "TYPE *elm" "TAILQ_ENTRY NAME"
@@ -67,6 +71,8 @@ Insertion of a new entry at the head of the list.
 .It
 Insertion of a new entry after any element in the list.
 .It
 .It
 Insertion of a new entry after any element in the list.
 .It
+Insertion of a new entry before any element in the list.
+.It
 Removal of any entry in the list.
 .It
 Forward traversal through the list.
 Removal of any entry in the list.
 .It
 Forward traversal through the list.
@@ -96,8 +102,6 @@ Circular queues add the following functionality:
 .It
 Entries can be added at the end of a list.
 .It
 .It
 Entries can be added at the end of a list.
 .It
-Entries can be added before another entry.
-.It
 They may be traversed backwards, from tail to head.
 .El
 However:
 They may be traversed backwards, from tail to head.
 .El
 However:
@@ -141,7 +145,7 @@ This structure contains a single pointer to the first element
 on the list.
 The elements are doubly linked so that an arbitrary element can be
 removed without traversing the list.
 on the list.
 The elements are doubly linked so that an arbitrary element can be
 removed without traversing the list.
-New elements can be added to the list after an existing element or
+New elements can be added to the list before or after an existing element or
 at the head of the list.
 A
 .Fa LIST_HEAD
 at the head of the list.
 A
 .Fa LIST_HEAD
@@ -190,6 +194,13 @@ after the element
 .Fa listelm .
 .Pp
 The macro
 .Fa listelm .
 .Pp
 The macro
+.Nm LIST_INSERT_BEFORE
+inserts the new element
+.Fa elm
+before the element
+.Fa listelm .
+.Pp
+The macro
 .Nm LIST_REMOVE
 removes the element
 .Fa elm
 .Nm LIST_REMOVE
 removes the element
 .Fa elm
@@ -211,6 +222,9 @@ LIST_INSERT_HEAD(&head, n1, entries);
 
 n2 = malloc(sizeof(struct entry));     /* Insert after. */
 LIST_INSERT_AFTER(n1, n2, entries);
 
 n2 = malloc(sizeof(struct entry));     /* Insert after. */
 LIST_INSERT_AFTER(n1, n2, entries);
+
+n2 = malloc(sizeof(struct entry));     /* Insert before. */
+LIST_INSERT_BEFORE(n1, n2, entries);
                                        /* Forward traversal. */
 for (np = head.lh_first; np != NULL; np = np->entries.le_next)
        np-> ...
                                        /* Forward traversal. */
 for (np = head.lh_first; np != NULL; np = np->entries.le_next)
        np-> ...
@@ -282,6 +296,13 @@ after the element
 .Fa listelm .
 .Pp
 The macro
 .Fa listelm .
 .Pp
 The macro
+.Nm TAILQ_INSERT_BEFORE
+inserts the new element
+.Fa elm
+before the element
+.Fa listelm .
+.Pp
+The macro
 .Nm TAILQ_REMOVE
 removes the element
 .Fa elm
 .Nm TAILQ_REMOVE
 removes the element
 .Fa elm
@@ -306,6 +327,9 @@ TAILQ_INSERT_TAIL(&head, n1, entries);
 
 n2 = malloc(sizeof(struct entry));     /* Insert after. */
 TAILQ_INSERT_AFTER(&head, n1, n2, entries);
 
 n2 = malloc(sizeof(struct entry));     /* Insert after. */
 TAILQ_INSERT_AFTER(&head, n1, n2, entries);
+
+n2 = malloc(sizeof(struct entry));     /* Insert before. */
+TAILQ_INSERT_BEFORE(&head, n1, n2, entries);
                                        /* Forward traversal. */
 for (np = head.tqh_first; np != NULL; np = np->entries.tqe_next)
        np-> ...
                                        /* Forward traversal. */
 for (np = head.tqh_first; np != NULL; np = np->entries.tqe_next)
        np-> ...