]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man7/queue.7
Many pages: Use .TP for tagged paragraphs
[thirdparty/man-pages.git] / man7 / queue.7
1 .\" Copyright (c) 1993
2 .\" The Regents of the University of California. All rights reserved.
3 .\" and Copyright (c) 2020 by Alejandro Colomar <colomar.6.4.3@gmail.com>
4 .\"
5 .\" SPDX-License-Identifier: BSD-3-Clause
6 .\"
7 .\"
8 .TH QUEUE 7 (date) "Linux man-pages (unreleased)"
9 .SH NAME
10 queue \- implementations of linked lists and queues
11 .SH DESCRIPTION
12 The
13 .I <sys/queue.h>
14 header file provides a set of macros that
15 define and operate on the following data structures:
16 .TP
17 SLIST
18 singly linked lists
19 .TP
20 LIST
21 doubly linked lists
22 .TP
23 STAILQ
24 singly linked tail queues
25 .TP
26 TAILQ
27 doubly linked tail queues
28 .TP
29 CIRCLEQ
30 doubly linked circular queues
31 .PP
32 All structures support the following functionality:
33 .IP * 3
34 Insertion of a new entry at the head of the list.
35 .IP *
36 Insertion of a new entry after any element in the list.
37 .IP *
38 O(1) removal of an entry from the head of the list.
39 .IP *
40 Forward traversal through the list.
41 .\".IP *
42 .\" Swapping the contents of two lists.
43 .PP
44 Code size and execution time
45 depend on the complexity of the data structure being used,
46 so programmers should take care to choose the appropriate one.
47 .SS Singly linked lists (SLIST)
48 Singly linked lists are the simplest
49 and support only the above functionality.
50 Singly linked lists are ideal for applications with
51 large datasets and few or no removals,
52 or for implementing a LIFO queue.
53 Singly linked lists add the following functionality:
54 .IP * 3
55 O(n) removal of any entry in the list.
56 .SS Singly linked tail queues (STAILQ)
57 Singly linked tail queues add the following functionality:
58 .IP * 3
59 Entries can be added at the end of a list.
60 .IP *
61 O(n) removal of any entry in the list.
62 .IP *
63 They may be concatenated.
64 .PP
65 However:
66 .IP * 3
67 All list insertions must specify the head of the list.
68 .IP *
69 Each head entry requires two pointers rather than one.
70 .PP
71 Singly linked tail queues are ideal for applications with
72 large datasets and few or no removals,
73 or for implementing a FIFO queue.
74 .SS Doubly linked data structures
75 All doubly linked types of data structures (lists and tail queues)
76 additionally allow:
77 .IP * 3
78 Insertion of a new entry before any element in the list.
79 .IP *
80 O(1) removal of any entry in the list.
81 .PP
82 However:
83 .IP * 3
84 Each element requires two pointers rather than one.
85 .SS Doubly linked lists (LIST)
86 Linked lists are the simplest of the doubly linked data structures.
87 They add the following functionality over the above:
88 .IP * 3
89 They may be traversed backwards.
90 .PP
91 However:
92 .IP * 3
93 To traverse backwards, an entry to begin the traversal and the list in
94 which it is contained must be specified.
95 .SS Doubly linked tail queues (TAILQ)
96 Tail queues add the following functionality:
97 .IP * 3
98 Entries can be added at the end of a list.
99 .IP *
100 They may be traversed backwards, from tail to head.
101 .IP *
102 They may be concatenated.
103 .PP
104 However:
105 .IP * 3
106 All list insertions and removals must specify the head of the list.
107 .IP *
108 Each head entry requires two pointers rather than one.
109 .SS Doubly linked circular queues (CIRCLEQ)
110 Circular queues add the following functionality over the above:
111 .IP * 3
112 The first and last entries are connected.
113 .PP
114 However:
115 .IP * 3
116 The termination condition for traversal is more complex.
117 .SH STANDARDS
118 Not in POSIX.1, POSIX.1-2001, or POSIX.1-2008.
119 Present on the BSDs.
120 .I <sys/queue.h>
121 macros first appeared in 4.4BSD.
122 .SH NOTES
123 Some BSDs provide SIMPLEQ instead of STAILQ.
124 They are identical, but for historical reasons
125 they were named differently on different BSDs.
126 STAILQ originated on FreeBSD, and SIMPLEQ originated on NetBSD.
127 For compatibility reasons, some systems provide both sets of macros.
128 Glibc provides both STAILQ and SIMPLEQ,
129 which are identical except for a missing SIMPLEQ equivalent to
130 .BR STAILQ_CONCAT ().
131 .SH SEE ALSO
132 .BR circleq (3),
133 .BR insque (3),
134 .BR list (3),
135 .BR slist (3),
136 .BR stailq (3),
137 .BR tailq (3)
138 .\" .BR tree (3)