queue(7)
โจ queue(7) โ the manual page, but make it a group chat โจ
okay bestie, so this is queue(7) from the Miscellaneous Information Manual, and it's literally the glow-up guide for <sys/queue.h> ๐ Like, this is the header that hands you a whole wardrobe of macros for building and living in linked lists and queues. No cap, it's giving foundational. Let's get into it. ๐ฆ
๐ธ NAME ๐ธ
queue โ implementations of linked lists and queues
๐ DESCRIPTION ๐
The <sys/queue.h> header file provides a set of macros that define and operate on the following data structures:
SLISTโ singly linked lists ๐LISTโ doubly linked listsSTAILQโ singly linked tail queuesTAILQโ doubly linked tail queuesCIRCLEQโ doubly linked circular queues ๐
All structures support the following functionality:
- Insertion of a new entry at the head of the list.
- Insertion of a new entry after any element in the list.
O(1)removal of an entry from the head of the list.- Forward traversal through the list.
lowkey important: code size and execution time depend on the complexity of the data structure being used, so programmers should take care to choose the appropriate one. Like, pick your fighter intentionally, don't just grab the first one. ๐
๐ Singly linked lists (SLIST) ๐
SLIST is the simplest of the bunch โ the baby of the family, the no-frills icon. It supports only the functionality listed above (head insertion, insert after any element, O(1) removal from the head, forward traversal) and nothing else.
Where it eats: SLIST is ideal for applications with large datasets and few or no removals, or for implementing a LIFO queue. โจ
SLIST adds the following functionality:
O(n)removal of any entry in the list.
๐ง Singly linked tail queues (STAILQ) ๐ง
STAILQ adds the following functionality:
- Entries can be added at the end of a list.
O(n)removal of any entry in the list.- They may be concatenated.
However:
- All list insertions must specify the head of the list.
- Each head entry requires two pointers rather than one.
STAILQ is ideal for applications with large datasets and few or no removals, or for implementing a FIFO queue. periodt. ๐
๐ Doubly linked data structures ๐
All doubly linked types of data structures (lists and tail queues) additionally allow:
- Insertion of a new entry before any element in the list.
O(1)removal of any entry in the list.
However:
- Each element requires two pointers rather than one.
like yeah, extra pointers, extra power. main character tax. ๐
๐ Doubly linked lists (LIST) ๐
LIST is the simplest of the doubly linked data structures. Over everything above, they add the following functionality:
- They may be traversed backwards.
However:
- To traverse backwards, an entry to begin the traversal and the list in which it is contained must be specified.
so like, backwards vibes require receipts. both of them. ๐ญ
โญ Doubly linked tail queues (TAILQ) โญ
TAILQ adds the following functionality:
- Entries can be added at the end of a list.
- They may be traversed backwards, from tail to head.
- They may be concatenated.
However:
- All list insertions and removals must specify the head of the list.
- Each head entry requires two pointers rather than one.
๐ฆ Doubly linked circular queues (CIRCLEQ) ๐ฆ
CIRCLEQ adds the following functionality over the above:
- The first and last entries are connected.
However:
- The termination condition for traversal is more complex.
fr fr, watch that termination condition. it's the plot twist of this whole data structure. ๐
๐ STANDARDS ๐
BSD.
๐ฐ๏ธ HISTORY ๐ฐ๏ธ
<sys/queue.h> macros first appeared in 4.4BSD.
๐ซถ NOTES ๐ซถ
Some BSDs provide SIMPLEQ instead of STAILQ. They are identical, but for historical reasons they were named differently on different BSDs. STAILQ originated on FreeBSD, and SIMPLEQ originated on NetBSD. For compatibility reasons, some systems provide both sets of macros. glibc provides both STAILQ and SIMPLEQ, which are identical except for a missing SIMPLEQ equivalent to STAILQ_CONCAT().
๐ SEE ALSO ๐
circleq(3), insque(3), list(3), slist(3), stailq(3), tailq(3)
and that's the whole page bestie, no skips, no crumbs left ๐ this one shipped as Linux man-pages 6.20, dated 2025-05-17 โ go forth and pick the right container, slay, and remember: choose your data structure like you choose your playlist. deliberately. ๐๐ซถโจ
๐ฆ where this page comes from
- arch rolling: man-pages 6.20-1 ยท BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages 6.20
- ๐ the page's license: BSD-3-Clause
- Copyright 1993, The Regents of the University of California
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms