{"id":5218,"date":"2022-12-20T18:37:13","date_gmt":"2022-12-20T21:37:13","guid":{"rendered":"http:\/\/lode.uno\/linux-man\/index.php\/2022\/12\/20\/insque-man3p\/"},"modified":"2022-12-20T18:37:13","modified_gmt":"2022-12-20T21:37:13","slug":"insque-man3p","status":"publish","type":"post","link":"https:\/\/lode.uno\/linux-man\/2022\/12\/20\/insque-man3p\/","title":{"rendered":"INSQUE (man3p)"},"content":{"rendered":"<h1 align=\"center\">INSQUE<\/h1>\n<p> <a href=\"#PROLOG\">PROLOG<\/a><br \/> <a href=\"#NAME\">NAME<\/a><br \/> <a href=\"#SYNOPSIS\">SYNOPSIS<\/a><br \/> <a href=\"#DESCRIPTION\">DESCRIPTION<\/a><br \/> <a href=\"#RETURN VALUE\">RETURN VALUE<\/a><br \/> <a href=\"#ERRORS\">ERRORS<\/a><br \/> <a href=\"#EXAMPLES\">EXAMPLES<\/a><br \/> <a href=\"#APPLICATION USAGE\">APPLICATION USAGE<\/a><br \/> <a href=\"#RATIONALE\">RATIONALE<\/a><br \/> <a href=\"#FUTURE DIRECTIONS\">FUTURE DIRECTIONS<\/a><br \/> <a href=\"#SEE ALSO\">SEE ALSO<\/a><br \/> <a href=\"#COPYRIGHT\">COPYRIGHT<\/a> <\/p>\n<hr>\n<h2>PROLOG <a name=\"PROLOG\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">This manual page is part of the POSIX Programmer\u2019s Manual. The Linux implementation of this interface may differ (consult the corresponding Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux.<\/p>\n<h2>NAME <a name=\"NAME\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">insque, remque \u2014 insert or remove an element in a queue<\/p>\n<h2>SYNOPSIS <a name=\"SYNOPSIS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">#include <search.h><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">void insque(void *<i>element<\/i>, void *<i>pred<\/i>); <br \/> void remque(void *<i>element<\/i>);<\/p>\n<h2>DESCRIPTION <a name=\"DESCRIPTION\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The <i>insque<\/i>() and <i>remque<\/i>() functions shall manipulate queues built from doubly-linked lists. The queue can be either circular or linear. An application using <i>insque<\/i>() or <i>remque<\/i>() shall ensure it defines a structure in which the first two members of the structure are pointers to the same type of structure, and any further members are application-specific. The first member of the structure is a forward pointer to the next entry in the queue. The second member is a backward pointer to the previous entry in the queue. If the queue is linear, the queue is terminated with null pointers. The names of the structure and of the pointer members are not subject to any special restriction.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The <i>insque<\/i>() function shall insert the element pointed to by <i>element<\/i> into a queue immediately after the element pointed to by <i>pred<\/i>.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The <i>remque<\/i>() function shall remove the element pointed to by <i>element<\/i> from a queue.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">If the queue is to be used as a linear list, invoking <i>insque<\/i>(&#038;<i>element<\/i>, NULL), where <i>element<\/i> is the initial element of the queue, shall initialize the forward and backward pointers of <i>element<\/i> to null pointers.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">If the queue is to be used as a circular list, the application shall ensure it initializes the forward pointer and the backward pointer of the initial element of the queue to the element\u2019s own address.<\/p>\n<h2>RETURN VALUE <a name=\"RETURN VALUE\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The <i>insque<\/i>() and <i>remque<\/i>() functions do not return a value.<\/p>\n<h2>ERRORS <a name=\"ERRORS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">No errors are defined.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>The following sections are informative.<\/i><\/p>\n<h2>EXAMPLES <a name=\"EXAMPLES\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><i><b>Creating a Linear Linked List<\/b><\/i> <br \/> The following example creates a linear linked list.<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">#include <search.h> <br \/> &#8230; <br \/> struct myque element1; <br \/> struct myque element2;<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">char *data1 = &#8220;DATA1&#8221;; <br \/> char *data2 = &#8220;DATA2&#8221;; <br \/> &#8230; <br \/> element1.data = data1; <br \/> element2.data = data2;<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">insque (&#038;element1, NULL); <br \/> insque (&#038;element2, &#038;element1);<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Creating a Circular Linked List<\/b> <br \/> The following example creates a circular linked list.<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">#include <search.h> <br \/> &#8230; <br \/> struct myque element1; <br \/> struct myque element2;<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">char *data1 = &#8220;DATA1&#8221;; <br \/> char *data2 = &#8220;DATA2&#8221;; <br \/> &#8230; <br \/> element1.data = data1; <br \/> element2.data = data2;<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">element1.fwd = &element1; <br \/> element1.bck = &element1;<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">insque (&#038;element2, &#038;element1);<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Removing an Element<\/b> <br \/> The following example removes the element pointed to by <i>element1<\/i>.<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">#include <search.h> <br \/> &#8230; <br \/> struct myque element1; <br \/> &#8230; <br \/> remque (&#038;element1);<\/p>\n<h2>APPLICATION USAGE <a name=\"APPLICATION USAGE\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The historical implementations of these functions described the arguments as being of type <b>struct qelem *<\/b> rather than as being of type <b>void *<\/b> as defined here. In those implementations, <b>struct qelem<\/b> was commonly defined in <i><search.h><\/i> as:<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">struct qelem { <br \/> struct qelem *q_forw; <br \/> struct qelem *q_back; <br \/> };<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Applications using these functions, however, were never able to use this structure directly since it provided no room for the actual data contained in the elements. Most applications defined structures that contained the two pointers as the initial elements and also provided space for, or pointers to, the object\u2019s data. Applications that used these functions to update more than one type of table also had the problem of specifying two or more different structures with the same name, if they literally used <b>struct qelem<\/b> as specified.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">As described here, the implementations were actually expecting a structure type where the first two members were forward and backward pointers to structures. With C compilers that didn\u2019t provide function prototypes, applications used structures as specified in the DESCRIPTION above and the compiler did what the application expected.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">If this method had been carried forward with an ISO\u00a0C standard compiler and the historical function prototype, most applications would have to be modified to cast pointers to the structures actually used to be pointers to <b>struct qelem<\/b> to avoid compilation warnings. By specifying <b>void *<\/b> as the argument type, applications do not need to change (unless they specifically referenced <b>struct qelem<\/b> and depended on it being defined in <i><search.h><\/i>).<\/p>\n<h2>RATIONALE <a name=\"RATIONALE\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">None.<\/p>\n<h2>FUTURE DIRECTIONS <a name=\"FUTURE DIRECTIONS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">None.<\/p>\n<h2>SEE ALSO <a name=\"SEE ALSO\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The Base Definitions volume of POSIX.1-2017, <b><search.h><\/b><\/p>\n<h2>COPYRIGHT <a name=\"COPYRIGHT\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology &#8212; Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http:\/\/www.opengroup.org\/unix\/online.html .<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https:\/\/www.kernel.org\/doc\/man-pages\/reporting_bugs.html .<\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>  insque, remque \u2014 insert or remove an element in a queue <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3779,1],"tags":[2108,1594],"class_list":["post-5218","post","type-post","status-publish","format-standard","hentry","category-3pm-perl-llamadas-de-bibliotecas","category-sin-categoria","tag-insque","tag-man3p"],"gutentor_comment":0,"_links":{"self":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/5218","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=5218"}],"version-history":[{"count":0,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/5218\/revisions"}],"wp:attachment":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/media?parent=5218"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/categories?post=5218"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/tags?post=5218"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}