1queue(7) Miscellaneous Information Manual queue(7)
2
3
4
6 queue - implementations of linked lists and queues
7
9 The <sys/queue.h> header file provides a set of macros that define and
10 operate on the following data structures:
11
12 SLIST singly linked lists
13
14 LIST doubly linked lists
15
16 STAILQ singly linked tail queues
17
18 TAILQ doubly linked tail queues
19
20 CIRCLEQ
21 doubly linked circular queues
22
23 All structures support the following functionality:
24
25 • Insertion of a new entry at the head of the list.
26
27 • Insertion of a new entry after any element in the list.
28
29 • O(1) removal of an entry from the head of the list.
30
31 • Forward traversal through the list.
32
33 Code size and execution time depend on the complexity of the data
34 structure being used, so programmers should take care to choose the ap‐
35 propriate one.
36
37 Singly linked lists (SLIST)
38 Singly linked lists are the simplest and support only the above func‐
39 tionality. Singly linked lists are ideal for applications with large
40 datasets and few or no removals, or for implementing a LIFO queue.
41 Singly linked lists add the following functionality:
42
43 • O(n) removal of any entry in the list.
44
45 Singly linked tail queues (STAILQ)
46 Singly linked tail queues add the following functionality:
47
48 • Entries can be added at the end of a list.
49
50 • O(n) removal of any entry in the list.
51
52 • They may be concatenated.
53
54 However:
55
56 • All list insertions must specify the head of the list.
57
58 • Each head entry requires two pointers rather than one.
59
60 Singly linked tail queues are ideal for applications with large
61 datasets and few or no removals, or for implementing a FIFO queue.
62
63 Doubly linked data structures
64 All doubly linked types of data structures (lists and tail queues) ad‐
65 ditionally allow:
66
67 • Insertion of a new entry before any element in the list.
68
69 • O(1) removal of any entry in the list.
70
71 However:
72
73 • Each element requires two pointers rather than one.
74
75 Doubly linked lists (LIST)
76 Linked lists are the simplest of the doubly linked data structures.
77 They add the following functionality over the above:
78
79 • They may be traversed backwards.
80
81 However:
82
83 • To traverse backwards, an entry to begin the traversal and the list
84 in which it is contained must be specified.
85
86 Doubly linked tail queues (TAILQ)
87 Tail queues add the following functionality:
88
89 • Entries can be added at the end of a list.
90
91 • They may be traversed backwards, from tail to head.
92
93 • They may be concatenated.
94
95 However:
96
97 • All list insertions and removals must specify the head of the list.
98
99 • Each head entry requires two pointers rather than one.
100
101 Doubly linked circular queues (CIRCLEQ)
102 Circular queues add the following functionality over the above:
103
104 • The first and last entries are connected.
105
106 However:
107
108 • The termination condition for traversal is more complex.
109
111 BSD.
112
114 <sys/queue.h> macros first appeared in 4.4BSD.
115
117 Some BSDs provide SIMPLEQ instead of STAILQ. They are identical, but
118 for historical reasons they were named differently on different BSDs.
119 STAILQ originated on FreeBSD, and SIMPLEQ originated on NetBSD. For
120 compatibility reasons, some systems provide both sets of macros. glibc
121 provides both STAILQ and SIMPLEQ, which are identical except for a
122 missing SIMPLEQ equivalent to STAILQ_CONCAT().
123
125 circleq(3), insque(3), list(3), slist(3), stailq(3), tailq(3)
126
127
128
129Linux man-pages 6.05 2023-03-30 queue(7)