1QUEUE(7)                   Linux Programmer's Manual                  QUEUE(7)
2
3
4

NAME

6       queue - implementations of linked lists and queues
7

DESCRIPTION

9       The  <sys/queue.h> header file provides a set of macros that define and
10       operate on the following data structures:
11
12       *  singly linked lists (SLIST)
13
14       *  doubly linked lists (LIST)
15
16       *  singly linked tail queues (STAILQ)
17
18       *  doubly linked tail queues (TAILQ)
19
20       *  doubly linked circular queues (CIRCLEQ)
21
22       All structures support the following functionality:
23
24       *  Insertion of a new entry at the head of the list.
25
26       *  Insertion of a new entry after any element in the list.
27
28       *  O(1) removal of an entry from the head of the list.
29
30       *  Forward traversal through the list.
31
32       Code size and execution time depend  on  the  complexity  of  the  data
33       structure being used, so programmers should take care to choose the ap‐
34       propriate one.
35
36   Singly linked lists (SLIST)
37       Singly linked lists are the simplest and support only the  above  func‐
38       tionality.   Singly  linked lists are ideal for applications with large
39       datasets and few or no removals, or  for  implementing  a  LIFO  queue.
40       Singly linked lists add the following functionality:
41
42       *  O(n) removal of any entry in the list.
43
44   Singly linked tail queues (STAILQ)
45       Singly linked tail queues add the following functionality:
46
47       *  Entries can be added at the end of a list.
48
49       *  O(n) removal of any entry in the list.
50
51       *  They may be concatenated.
52
53       However:
54
55       *  All list insertions must specify the head of the list.
56
57       *  Each head entry requires two pointers rather than one.
58
59       Singly  linked  tail  queues  are  ideal  for  applications  with large
60       datasets and few or no removals, or for implementing a FIFO queue.
61
62   Doubly linked data structures
63       All doubly linked types of data structures (lists and tail queues)  ad‐
64       ditionally allow:
65
66       *  Insertion of a new entry before any element in the list.
67
68       *  O(1) removal of any entry in the list.
69
70       However:
71
72       *  Each element requires two pointers rather than one.
73
74   Doubly linked lists (LIST)
75       Linked  lists  are  the  simplest of the doubly linked data structures.
76       They add the following functionality over the above:
77
78       *  They may be traversed backwards.
79
80       However:
81
82       *  To traverse backwards, an entry to begin the traversal and the  list
83          in which it is contained must be specified.
84
85   Doubly linked tail queues (TAILQ)
86       Tail queues add the following functionality:
87
88       *  Entries can be added at the end of a list.
89
90       *  They may be traversed backwards, from tail to head.
91
92       *  They may be concatenated.
93
94       However:
95
96       *  All list insertions and removals must specify the head of the list.
97
98       *  Each head entry requires two pointers rather than one.
99
100   Doubly linked circular queues (CIRCLEQ)
101       Circular queues add the following functionality over the above:
102
103       *  The first and last entries are connected.
104
105       However:
106
107       *  The termination condition for traversal is more complex.
108

CONFORMING TO

110       Not  in  POSIX.1,  POSIX.1-2001, or POSIX.1-2008.  Present on the BSDs.
111       <sys/queue.h> macros first appeared in 4.4BSD.
112

NOTES

114       Some BSDs provide SIMPLEQ instead of STAILQ.  They are  identical,  but
115       for  historical  reasons they were named differently on different BSDs.
116       STAILQ originated on FreeBSD, and SIMPLEQ originated  on  NetBSD.   For
117       compatibility reasons, some systems provide both sets of macros.  Glibc
118       provides both STAILQ and SIMPLEQ, which  are  identical  except  for  a
119       missing SIMPLEQ equivalent to STAILQ_CONCAT().
120

SEE ALSO

122       circleq(3), insque(3), list(3), slist(3), stailq(3), tailq(3)
123

COLOPHON

125       This  page  is  part of release 5.13 of the Linux man-pages project.  A
126       description of the project, information about reporting bugs,  and  the
127       latest     version     of     this    page,    can    be    found    at
128       https://www.kernel.org/doc/man-pages/.
129
130
131
132GNU                               2021-03-22                          QUEUE(7)
Impressum