insque.html
来自「unix 下的C开发手册,还用详细的例程。」· HTML 代码 · 共 119 行
HTML
119 行
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html><head><!-- Copyright 1997 The Open Group, All Rights Reserved --><title>insque</title></head><body bgcolor=white><center><font size=2>The Single UNIX ® Specification, Version 2<br>Copyright © 1997 The Open Group</font></center><hr size=2 noshade><h4><a name = "tag_000_005_977"> </a>NAME</h4><blockquote>insque, remque - insert or remove an element in a queue</blockquote><h4><a name = "tag_000_005_978"> </a>SYNOPSIS</h4><blockquote><pre><code>#include <<a href="search.h.html">search.h</a>>void insque(void *<i>element</i>, void *<i>pred</i>);void remque(void *<i>element</i>);</code></pre></blockquote><h4><a name = "tag_000_005_979"> </a>DESCRIPTION</h4><blockquote>The<i>insque()</i>and<i><a href="remque.html">remque()</a></i>functions manipulate queues built from doubly-linked lists. The queue can beeither circular or linear. An application using<i>insque()</i>or<i><a href="remque.html">remque()</a></i>must define a structure in which the first two members of the structure arepointers to the same type of structure, and any further members areapplication-specific. The first member of the structure is a forward pointerto the next entry in the queue. The second member is a backward pointer tothe previous entry in the queue. If the queue is linear, the queue isterminated with null pointers. The names of the structure and of the pointermembers are not subject to any special restriction.<p>The<i>insque()</i>function inserts the element pointed to by <i>element</i> into aqueue immediately after the element pointed to by <i>pred</i>.<p>The<i><a href="remque.html">remque()</a></i>function removes the element pointed to by <i>element</i> from a queue.<p>If the queue is to be used as a linear list, invoking<i>insque</i>(&<i>element</i>, NULL), where <i>element</i> is the initialelement of the queue, will initialise the forward and backward pointers of<i>element</i> to null pointers.<p>If the queue is to be used as a circular list, the application must initialisethe forward pointer and the backward pointer of the initial element of thequeue to the element's own address.</blockquote><h4><a name = "tag_000_005_980"> </a>RETURN VALUE</h4><blockquote>The<i>insque()</i>and<i><a href="remque.html">remque()</a></i>functions do not return a value.</blockquote><h4><a name = "tag_000_005_981"> </a>ERRORS</h4><blockquote>No errors are defined.</blockquote><h4><a name = "tag_000_005_982"> </a>EXAMPLES</h4><blockquote>None.</blockquote><h4><a name = "tag_000_005_983"> </a>APPLICATION USAGE</h4><blockquote>The historical implementations of these functions described thearguments as being of type <b>struct qelem *</b> rather than as beingof type <b>void *</b> as defined here. In those implementations,<b>struct qelem</b> was commonly defined in <<b>search.h</b>> as:<pre><code>struct qelem { struct qelem *q_forw; struct qelem *q_back;};</code></pre>Applications using these functions, however, were never able touse this structure directly since it provided no room forthe actual data contained in the elements. Most applicationsdefined structures that contained the two pointers as theinitial elements and also provided space for, or pointers to,the object's data. Applications that used these functions toupdate more than one type of table also had the problem ofspecifying two or more different structures with the samename, if they literally used <b>struct qelem</b> as specified.<p>As described here, the implementations were actually expectinga structure type where the first two members were forward andbackward pointers to structures. With C compilers that didn'tprovide function prototypes, applications used structures asspecified in the DESCRIPTION above and the compiler did whatthe application expected.<p>If this method had been carried forward with an ISO C compilerand the historical function prototype, most applications wouldhave to be modified to cast pointers to the structures actuallyused to be pointers to <b>struct qelem</b> to avoid compilationwarnings. By specifying <b>void *</b> as the argument type,applications won't need to change (unless they specificallyreferenced <b>struct qelem</b> and depended on it being defined in<<b>search.h</b>>).</blockquote><h4><a name = "tag_000_005_984"> </a>FUTURE DIRECTIONS</h4><blockquote>None.</blockquote><h4><a name = "tag_000_005_985"> </a>SEE ALSO</h4><blockquote><i><a href="search.h.html"><search.h></a></i>.</blockquote><hr size=2 noshade><center><font size=2>UNIX ® is a registered Trademark of The Open Group.<br>Copyright © 1997 The Open Group<br> [ <a href="../index.html">Main Index</a> | <a href="../xshix.html">XSH</a> | <a href="../xcuix.html">XCU</a> | <a href="../xbdix.html">XBD</a> | <a href="../cursesix.html">XCURSES</a> | <a href="../xnsix.html">XNS</a> ]</font></center><hr size=2 noshade></body></html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?