qvaluestack.html

来自「QT 下载资料仅供参考」· HTML 代码 · 共 157 行

HTML
157
字号
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><!-- /home/reggie/tmp/qt-3.0-reggie-5401/qt-x11-commercial-3.0.5/doc/qvaluestack.doc:41 --><html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>QValueStack Class</title><style type="text/css"><!--h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }a:link { color: #004faf; text-decoration: none }a:visited { color: #672967; text-decoration: none }body { background: #ffffff; color: black; }--></style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr bgcolor="#E5E5E5"><td valign=center> <a href="index.html"><font color="#004faf">Home</font></a> | <a href="classes.html"><font color="#004faf">All&nbsp;Classes</font></a> | <a href="mainclasses.html"><font color="#004faf">Main&nbsp;Classes</font></a> | <a href="annotated.html"><font color="#004faf">Annotated</font></a> | <a href="groups.html"><font color="#004faf">Grouped&nbsp;Classes</font></a> | <a href="functions.html"><font color="#004faf">Functions</font></a></td><td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QValueStack Class Reference</h1><p>The QValueStack class is a value-based template class that provides a stack.<a href="#details">More...</a><p><tt>#include &lt;<a href="qvaluestack-h.html">qvaluestack.h</a>&gt;</tt><p>Inherits <a href="qvaluelist.html">QValueList</a>&lt;T&gt;.<p><a href="qvaluestack-members.html">List of all member functions.</a><h2>Public Members</h2><ul><li><div class=fn><a href="#QValueStack"><b>QValueStack</b></a> ()</div></li><li><div class=fn><a href="#~QValueStack"><b>~QValueStack</b></a> ()</div></li><li><div class=fn>void <a href="#push"><b>push</b></a> ( const&nbsp;T&nbsp;&amp;&nbsp;d )</div></li><li><div class=fn>T <a href="#pop"><b>pop</b></a> ()</div></li><li><div class=fn>T &amp; <a href="#top"><b>top</b></a> ()</div></li><li><div class=fn>const T &amp; <a href="#top-2"><b>top</b></a> () const</div></li></ul><hr><a name="details"></a><h2>Detailed Description</h2>The QValueStack class is a value-based template class that provides a stack.<p> <p> Define a template instance QValueStack&lt;X&gt; to create a stack ofvalues that all have the class X. QValueStack is part of the <a href="qtl.html">Qt Template Library</a>.<p> Note that QValueStack does not store pointers to the members of thestack; it holds a copy of every member. That is why these kinds ofclasses are called "value based"; <a href="qptrstack.html">QPtrStack</a>, <a href="qptrlist.html">QPtrList</a>, and <a href="qdict.html">QDict</a> are"reference based".<p> A stack is a last in, first ut (LIFO) structure. Items are added tothe top of the stack with <a href="#push">push</a>() and retrieved from the top with<a href="#pop">pop</a>(). Furthermore, <a href="#top">top</a>() provides access to the topmost itemwithout removing it.<p> Example:<pre>    QValueStack&lt;int&gt; stack;    stack.<a href="#push">push</a>( 1 );    stack.<a href="#push">push</a>( 2 );    stack.<a href="#push">push</a>( 3 );    while ( ! stack.<a href="qvaluelist.html#isEmpty">isEmpty</a>() )        cout &lt;&lt; "Item: " &lt;&lt; stack.<a href="#pop">pop</a>() &lt;&lt; endl;    // Output:    //  Item: 3    //  Item: 2    //  Item: 1  </pre> <p> QValueStack is a specialized <a href="qvaluelist.html">QValueList</a> provided forconvenience. All of QValueList's functionality also applies toQPtrStack, for example the facility to iterate over all elements usingQValueStack<T>::Iterator. See <a href="qvaluelistiterator.html">QValueListIterator</a> for further details.<p> Some classes cannot be used within a QValueStack, for example everythingderived from <a href="qobject.html">QObject</a> and thus all classes that implement widgets.Only values can be used in a QValueStack. To qualify as a value, the classmust provide<ul><li> A copy constructor<li> An assignment operator<li> A default constructor, i.e. a constructor that does not take any arguments.</ul><p> Note that C++ defaults to field-by-field assignment operators andcopy constructors if no explicit version is supplied. In many casesthis is sufficient.<p> <p>See also <a href="qtl.html">Qt Template Library Classes</a>, <a href="shared.html">Implicitly and Explicitly Shared Classes</a> and <a href="tools.html">Non-GUI Classes</a>.<hr><h2>Member Function Documentation</h2><h3 class=fn><a name="QValueStack"></a>QValueStack::QValueStack ()</h3><p> Constructs an empty stack.<h3 class=fn><a name="~QValueStack"></a>QValueStack::~QValueStack ()</h3><p> Destroys the stack. References to the values in the stack and alliterators of this stack become invalidated. Because QValueStack ishighly tuned for performance, you won't see warnings if you useinvalid iterators because it is impossible for an iterator to checkwhether or not it is valid.<h3 class=fn>T <a name="pop"></a>QValueStack::pop ()</h3><p> Removes the top item from the stack and returns it.<p> <p>See also <a href="#top">top</a>() and <a href="#push">push</a>().<h3 class=fn>void <a name="push"></a>QValueStack::push ( const&nbsp;T&nbsp;&amp;&nbsp;d )</h3><p> Adds element, <em>d</em>, to the top of the stack.  Last in, first out.<p> This function is equivalent to <a href="qvaluelist.html#append">append</a>().<p> <p>See also <a href="#pop">pop</a>() and <a href="#top">top</a>().<h3 class=fn>T &amp; <a name="top"></a>QValueStack::top ()</h3><p> Returns a reference to the top item of the stack or the itemreferenced by <a href="qvaluelist.html#end">end</a>() if nosuch item exists. Note that you must not changethe value the end() iterator points to.<p> This function is equivalent to <a href="qvaluelist.html#last">last</a>().<p> <p>See also <a href="#pop">pop</a>(), <a href="#push">push</a>() and <a href="qvaluelist.html#fromLast">QValueList::fromLast</a>().<h3 class=fn>const T &amp; <a name="top-2"></a>QValueStack::top () const</h3>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.<p> Returns a reference to the top item of the stack or the itemreferenced by <a href="qvaluelist.html#end">end</a>() if no such item exists.<p> This function is equivalent to <a href="qvaluelist.html#last">last</a>().<p> <p>See also <a href="#pop">pop</a>(), <a href="#push">push</a>() and <a href="qvaluelist.html#fromLast">QValueList::fromLast</a>().<!-- eof --><hr><p>This file is part of the <a href="index.html">Qt toolkit</a>.Copyright &copy; 1995-2002<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center><table width=100% cellspacing=0 border=0><tr><td>Copyright &copy; 2002 <a href="http://www.trolltech.com">Trolltech</a><td><a href="http://www.trolltech.com/trademarks.html">Trademarks</a><td align=right><div align=right>Qt version 3.0.5</div></table></div></address></body></html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?