{"id":4119,"date":"2022-12-20T17:39:27","date_gmt":"2022-12-20T20:39:27","guid":{"rendered":"http:\/\/lode.uno\/linux-man\/index.php\/2022\/12\/20\/queue-man7\/"},"modified":"2022-12-20T17:39:27","modified_gmt":"2022-12-20T20:39:27","slug":"queue-man7","status":"publish","type":"post","link":"https:\/\/lode.uno\/linux-man\/2022\/12\/20\/queue-man7\/","title":{"rendered":"QUEUE (man7)"},"content":{"rendered":"<h1 align=\"center\">QUEUE<\/h1>\n<p> <a href=\"#NAME\">NAME<\/a><br \/> <a href=\"#DESCRIPTION\">DESCRIPTION<\/a><br \/> <a href=\"#CONFORMING TO\">CONFORMING TO<\/a><br \/> <a href=\"#SEE ALSO\">SEE ALSO<\/a><br \/> <a href=\"#COLOPHON\">COLOPHON<\/a> <\/p>\n<hr>\n<h2>NAME <a name=\"NAME\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">queue \u2212 implementations of linked lists and queues<\/p>\n<h2>DESCRIPTION <a name=\"DESCRIPTION\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The <i><sys\/queue.h><\/i> header file provides a set of macros that define and operate on the following data structures:<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p>*<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"60%\">\n<p>singly linked lists (SLIST)<\/p>\n<\/td>\n<td width=\"25%\"> <\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p>*<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"60%\">\n<p>doubly linked lists (LIST)<\/p>\n<\/td>\n<td width=\"25%\"> <\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p>*<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"60%\">\n<p>singly linked tail queues (STAILQ)<\/p>\n<\/td>\n<td width=\"25%\"> <\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p>*<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"60%\">\n<p>doubly linked tail queues (TAILQ)<\/p>\n<\/td>\n<td width=\"25%\"> <\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p>*<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"60%\">\n<p>doubly linked circular queues (CIRCLEQ)<\/p>\n<\/td>\n<td width=\"25%\"> <\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:11%; margin-top: 1em\">All structures support the following functionality:<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p style=\"margin-top: 1em\">*<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"85%\">\n<p style=\"margin-top: 1em\">Insertion of a new entry at the head of the list.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p>*<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"85%\">\n<p>Insertion of a new entry after any element in the list.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p>*<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"85%\">\n<p>O(1) removal of an entry from the head of the list.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p>*<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"85%\">\n<p>Forward traversal through the list.<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:11%; margin-top: 1em\">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.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Singly linked lists (SLIST)<\/b> <br \/> Singly linked lists are the simplest and support only the above functionality. Singly linked lists are ideal for applications with large datasets and few or no removals, or for implementing a LIFO queue. Singly linked lists add the following functionality:<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p style=\"margin-top: 1em\">*<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"59%\">\n<p style=\"margin-top: 1em\">O(n) removal of any entry in the list.<\/p>\n<\/td>\n<td width=\"26%\"> <\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Singly linked tail queues (STAILQ)<\/b> <br \/> Singly linked tail queues add the following functionality:<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p style=\"margin-top: 1em\">*<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"65%\">\n<p style=\"margin-top: 1em\">Entries can be added at the end of a list.<\/p>\n<\/td>\n<td width=\"20%\"> <\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p>*<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"65%\">\n<p>O(n) removal of any entry in the list.<\/p>\n<\/td>\n<td width=\"20%\"> <\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p>*<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"65%\">\n<p>They may be concatenated.<\/p>\n<\/td>\n<td width=\"20%\"> <\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:11%; margin-top: 1em\">However:<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p style=\"margin-top: 1em\">*<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"83%\">\n<p style=\"margin-top: 1em\">All list insertions must specify the head of the list.<\/p>\n<\/td>\n<td width=\"2%\"> <\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p>*<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"83%\">\n<p>Each head entry requires two pointers rather than one.<\/p>\n<\/td>\n<td width=\"2%\"> <\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:11%; margin-top: 1em\">Singly linked tail queues are ideal for applications with large datasets and few or no removals, or for implementing a FIFO queue.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Doubly linked data structures<\/b> <br \/> All doubly linked types of data structures (lists and tail queues) additionally allow:<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p style=\"margin-top: 1em\">*<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"85%\">\n<p style=\"margin-top: 1em\">Insertion of a new entry before any element in the list.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p>*<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"85%\">\n<p>O(1) removal of any entry in the list.<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:11%; margin-top: 1em\">However:<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p style=\"margin-top: 1em\">*<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"79%\">\n<p style=\"margin-top: 1em\">Each element requires two pointers rather than one.<\/p>\n<\/td>\n<td width=\"6%\"> <\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Doubly linked lists (LIST)<\/b> <br \/> Linked lists are the simplest of the doubly linked data structures. They add the following functionality over the above:<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p style=\"margin-top: 1em\">*<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"50%\">\n<p style=\"margin-top: 1em\">They may be traversed backwards.<\/p>\n<\/td>\n<td width=\"35%\"> <\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:11%; margin-top: 1em\">However:<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p style=\"margin-top: 1em\">*<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"85%\">\n<p style=\"margin-top: 1em\">To traverse backwards, an entry to begin the traversal and the list in which it is contained must be specified.<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Doubly linked tail queues (TAILQ)<\/b> <br \/> Tail queues add the following functionality:<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p style=\"margin-top: 1em\">*<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"79%\">\n<p style=\"margin-top: 1em\">Entries can be added at the end of a list.<\/p>\n<\/td>\n<td width=\"6%\"> <\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p>*<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"79%\">\n<p>They may be traversed backwards, from tail to head.<\/p>\n<\/td>\n<td width=\"6%\"> <\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p>*<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"79%\">\n<p>They may be concatenated.<\/p>\n<\/td>\n<td width=\"6%\"> <\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:11%; margin-top: 1em\">However:<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p style=\"margin-top: 1em\">*<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"85%\">\n<p style=\"margin-top: 1em\">All list insertions and removals must specify the head of the list.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p>*<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"85%\">\n<p>Each head entry requires two pointers rather than one.<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Doubly linked circular queues (CIRCLEQ)<\/b> <br \/> Circular queues add the following functionality over the above:<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p style=\"margin-top: 1em\">*<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"63%\">\n<p style=\"margin-top: 1em\">The first and last entries are connected.<\/p>\n<\/td>\n<td width=\"22%\"> <\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:11%; margin-top: 1em\">However:<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p style=\"margin-top: 1em\">*<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"85%\">\n<p style=\"margin-top: 1em\">The termination condition for traversal is more complex.<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<h2>CONFORMING TO <a name=\"CONFORMING TO\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Not in POSIX.1, POSIX.1-2001 or POSIX.1-2008. Present on the BSDs. <i><sys\/queue.h><\/i> macros first appeared in 4.4BSD.<\/p>\n<h2>SEE ALSO <a name=\"SEE ALSO\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>circleq<\/b>(3), <b>insque<\/b>(3), <b>list<\/b>(3), <b>slist<\/b>(3), <b>stailq<\/b>(3), <b>tailq<\/b>(3)<\/p>\n<h2>COLOPHON <a name=\"COLOPHON\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">This page is part of release 5.10 of the Linux <i>man-pages<\/i> project. A description of the project, information about reporting bugs, and the latest version of this page, can be found at https:\/\/www.kernel.org\/doc\/man\u2212pages\/.<\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>  queue \u2212 implementations of linked lists and queues <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[971],"tags":[973,972,1198],"class_list":["post-4119","post","type-post","status-publish","format-standard","hentry","category-7-miscelanea","tag-973","tag-man7","tag-queue"],"gutentor_comment":0,"_links":{"self":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/4119","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/comments?post=4119"}],"version-history":[{"count":0,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/4119\/revisions"}],"wp:attachment":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/media?parent=4119"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/categories?post=4119"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/tags?post=4119"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}