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>
5 .\" SPDX-License-Identifier: BSD-3-Clause
8 .TH QUEUE 7 (date) "Linux man-pages (unreleased)"
10 queue \- implementations of linked lists and queues
14 header file provides a set of macros that
15 define and operate on the following data structures:
24 singly linked tail queues
27 doubly linked tail queues
30 doubly linked circular queues
32 All structures support the following functionality:
34 Insertion of a new entry at the head of the list.
36 Insertion of a new entry after any element in the list.
38 O(1) removal of an entry from the head of the list.
40 Forward traversal through the list.
42 .\" Swapping the contents of two lists.
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:
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:
59 Entries can be added at the end of a list.
61 O(n) removal of any entry in the list.
63 They may be concatenated.
67 All list insertions must specify the head of the list.
69 Each head entry requires two pointers rather than one.
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)
78 Insertion of a new entry before any element in the list.
80 O(1) removal of any entry in the list.
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:
89 They may be traversed backwards.
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:
98 Entries can be added at the end of a list.
100 They may be traversed backwards, from tail to head.
102 They may be concatenated.
106 All list insertions and removals must specify the head of the list.
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:
112 The first and last entries are connected.
116 The termination condition for traversal is more complex.
118 Not in POSIX.1, POSIX.1-2001, or POSIX.1-2008.
121 macros first appeared in 4.4BSD.
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 ().