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"><!--
|
---|
8 | fn { margin-left: 1cm; text-indent: -1cm; }
|
---|
9 | a:link { color: #004faf; text-decoration: none }
|
---|
10 | a:visited { color: #672967; text-decoration: none }
|
---|
11 | body { 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 Classes</font></a>
|
---|
23 | | <a href="mainclasses.html">
|
---|
24 | <font color="#004faf">Main 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 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 <<a href="qvaluestack-h.html">qvaluestack.h</a>></tt>
|
---|
38 | <p>Inherits <a href="qvaluelist.html">QValueList</a><T>.
|
---|
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 T & d )</li>
|
---|
45 | <li class=fn>T <a href="#pop"><b>pop</b></a> ()</li>
|
---|
46 | <li class=fn>T & <a href="#top"><b>top</b></a> ()</li>
|
---|
47 | <li class=fn>const T & <a href="#top-2"><b>top</b></a> () const</li>
|
---|
48 | </ul>
|
---|
49 | <hr><a name="details"></a><h2>Detailed Description</h2>
|
---|
50 |
|
---|
51 |
|
---|
52 | The 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<X> to create a stack of
|
---|
59 | values 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
|
---|
61 | the stack; it holds a copy of every member. That is why these
|
---|
62 | kinds 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
|
---|
65 | to the top of the stack with <a href="#push">push</a>() and retrieved from the top
|
---|
66 | with <a href="#pop">pop</a>(). The <a href="#top">top</a>() function provides access to the topmost item
|
---|
67 | without removing it.
|
---|
68 | <p> Example:
|
---|
69 | <pre>
|
---|
70 | QValueStack<int> 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 << "Item: " << stack.<a href="#pop">pop</a>() << 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.
|
---|
84 | All of QValueList's functionality also applies to <a href="qptrstack.html">QPtrStack</a>, for
|
---|
85 | example the facility to iterate over all elements using
|
---|
86 | QValueStack<T>::Iterator. See <a href="qvaluelistiterator.html">QValueListIterator</a> for further
|
---|
87 | details.
|
---|
88 | <p> Some classes cannot be used within a QValueStack, for example
|
---|
89 | everything derived from <a href="qobject.html">QObject</a> and thus all classes that
|
---|
90 | implement widgets. Only values can be used in a QValueStack. To
|
---|
91 | qualify 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
|
---|
98 | copy constructors if no explicit version is supplied. In many
|
---|
99 | cases 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
|
---|
112 | iterators of this stack become invalidated. Because QValueStack is
|
---|
113 | highly tuned for performance, you won't see warnings if you use
|
---|
114 | invalid iterators because it is impossible for an iterator to
|
---|
115 | check 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 T & 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 & <a name="top"></a>QValueStack::top ()
|
---|
131 | </h3>
|
---|
132 |
|
---|
133 | <p> Returns a reference to the top item of the stack or the item
|
---|
134 | referenced by <a href="qvaluelist.html#end">end</a>() if no such item exists. Note that you must not
|
---|
135 | change 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 & <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
|
---|
144 | referenced 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>
|
---|
150 | This file is part of the <a href="index.html">Qt toolkit</a>.
|
---|
151 | Copyright © 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 © 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>
|
---|