source: trunk/doc/html/qvaluestack.html

Last change on this file was 190, checked in by rudi, 14 years ago

reference documentation added

File size: 7.2 KB
Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/doc/qvaluestack.doc:41 -->
3<html>
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
6<title>QValueStack Class</title>
7<style type="text/css"><!--
8fn { margin-left: 1cm; text-indent: -1cm; }
9a:link { color: #004faf; text-decoration: none }
10a:visited { color: #672967; text-decoration: none }
11body { background: #ffffff; color: black; }
12--></style>
13</head>
14<body>
15
16<table border="0" cellpadding="0" cellspacing="0" width="100%">
17<tr bgcolor="#E5E5E5">
18<td valign=center>
19 <a href="index.html">
20<font color="#004faf">Home</font></a>
21 | <a href="classes.html">
22<font color="#004faf">All&nbsp;Classes</font></a>
23 | <a href="mainclasses.html">
24<font color="#004faf">Main&nbsp;Classes</font></a>
25 | <a href="annotated.html">
26<font color="#004faf">Annotated</font></a>
27 | <a href="groups.html">
28<font color="#004faf">Grouped&nbsp;Classes</font></a>
29 | <a href="functions.html">
30<font color="#004faf">Functions</font></a>
31</td>
32<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>
33
34<p>The QValueStack class is a value-based template class that provides a stack.
35<a href="#details">More...</a>
36<p>All the functions in this class are <a href="threads.html#reentrant">reentrant</a> when Qt is built with thread support.</p>
37<p><tt>#include &lt;<a href="qvaluestack-h.html">qvaluestack.h</a>&gt;</tt>
38<p>Inherits <a href="qvaluelist.html">QValueList</a>&lt;T&gt;.
39<p><a href="qvaluestack-members.html">List of all member functions.</a>
40<h2>Public Members</h2>
41<ul>
42<li class=fn><a href="#QValueStack"><b>QValueStack</b></a> ()</li>
43<li class=fn><a href="#~QValueStack"><b>~QValueStack</b></a> ()</li>
44<li class=fn>void <a href="#push"><b>push</b></a> ( const&nbsp;T&nbsp;&amp;&nbsp;d )</li>
45<li class=fn>T <a href="#pop"><b>pop</b></a> ()</li>
46<li class=fn>T &amp; <a href="#top"><b>top</b></a> ()</li>
47<li class=fn>const T &amp; <a href="#top-2"><b>top</b></a> () const</li>
48</ul>
49<hr><a name="details"></a><h2>Detailed Description</h2>
50
51
52The QValueStack class is a value-based template class that provides a stack.
53<p>
54
55
56
57
58<p> Define a template instance QValueStack&lt;X&gt; to create a stack of
59values that all have the class X. QValueStack is part of the <a href="qtl.html">Qt Template Library</a>.
60<p> Note that QValueStack does not store pointers to the members of
61the stack; it holds a copy of every member. That is why these
62kinds of classes are called "value based"; <a href="qptrstack.html">QPtrStack</a>, <a href="qptrlist.html">QPtrList</a>,
63<a href="qdict.html">QDict</a>, etc., are "pointer based".
64<p> A stack is a last in, first out (LIFO) structure. Items are added
65to the top of the stack with <a href="#push">push</a>() and retrieved from the top
66with <a href="#pop">pop</a>(). The <a href="#top">top</a>() function provides access to the topmost item
67without removing it.
68<p> Example:
69<pre>
70 QValueStack&lt;int&gt; stack;
71 stack.<a href="#push">push</a>( 1 );
72 stack.<a href="#push">push</a>( 2 );
73 stack.<a href="#push">push</a>( 3 );
74 while ( ! stack.<a href="qvaluelist.html#isEmpty">isEmpty</a>() )
75 cout &lt;&lt; "Item: " &lt;&lt; stack.<a href="#pop">pop</a>() &lt;&lt; endl;
76
77 // Output:
78 // Item: 3
79 // Item: 2
80 // Item: 1
81 </pre>
82
83<p> QValueStack is a specialized <a href="qvaluelist.html">QValueList</a> provided for convenience.
84All of QValueList's functionality also applies to <a href="qptrstack.html">QPtrStack</a>, for
85example the facility to iterate over all elements using
86QValueStack<T>::Iterator. See <a href="qvaluelistiterator.html">QValueListIterator</a> for further
87details.
88<p> Some classes cannot be used within a QValueStack, for example
89everything derived from <a href="qobject.html">QObject</a> and thus all classes that
90implement widgets. Only values can be used in a QValueStack. To
91qualify as a value, the class must provide
92<ul>
93<li> a copy constructor;
94<li> an assignment operator;
95<li> a default constructor, i.e. a constructor that does not take any arguments.
96</ul>
97<p> Note that C++ defaults to field-by-field assignment operators and
98copy constructors if no explicit version is supplied. In many
99cases this is sufficient.
100<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>.
101
102<hr><h2>Member Function Documentation</h2>
103<h3 class=fn><a name="QValueStack"></a>QValueStack::QValueStack ()
104</h3>
105
106<p> Constructs an empty stack.
107
108<h3 class=fn><a name="~QValueStack"></a>QValueStack::~QValueStack ()
109</h3>
110
111<p> Destroys the stack. References to the values in the stack and all
112iterators of this stack become invalidated. Because QValueStack is
113highly tuned for performance, you won't see warnings if you use
114invalid iterators because it is impossible for an iterator to
115check whether or not it is valid.
116
117<h3 class=fn>T <a name="pop"></a>QValueStack::pop ()
118</h3>
119
120<p> Removes the top item from the stack and returns it.
121<p> <p>See also <a href="#top">top</a>() and <a href="#push">push</a>().
122
123<h3 class=fn>void <a name="push"></a>QValueStack::push ( const&nbsp;T&nbsp;&amp;&nbsp;d )
124</h3>
125
126<p> Adds element, <em>d</em>, to the top of the stack. Last in, first out.
127<p> This function is equivalent to <a href="qvaluelist.html#append">append</a>().
128<p> <p>See also <a href="#pop">pop</a>() and <a href="#top">top</a>().
129
130<h3 class=fn>T &amp; <a name="top"></a>QValueStack::top ()
131</h3>
132
133<p> Returns a reference to the top item of the stack or the item
134referenced by <a href="qvaluelist.html#end">end</a>() if no such item exists. Note that you must not
135change the value the end() iterator points to.
136<p> This function is equivalent to <a href="qvaluelist.html#last">last</a>().
137<p> <p>See also <a href="#pop">pop</a>(), <a href="#push">push</a>(), and <a href="qvaluelist.html#fromLast">QValueList::fromLast</a>().
138
139<h3 class=fn>const T &amp; <a name="top-2"></a>QValueStack::top () const
140</h3>
141
142<p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
143<p> Returns a reference to the top item of the stack or the item
144referenced by <a href="qvaluelist.html#end">end</a>() if no such item exists.
145<p> This function is equivalent to <a href="qvaluelist.html#last">last</a>().
146<p> <p>See also <a href="#pop">pop</a>(), <a href="#push">push</a>(), and <a href="qvaluelist.html#fromLast">QValueList::fromLast</a>().
147
148<!-- eof -->
149<hr><p>
150This file is part of the <a href="index.html">Qt toolkit</a>.
151Copyright &copy; 1995-2007
152<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
153<table width=100% cellspacing=0 border=0><tr>
154<td>Copyright &copy; 2007
155<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
156<td align=right><div align=right>Qt 3.3.8</div>
157</table></div></address></body>
158</html>
Note: See TracBrowser for help on using the repository browser.