summaryrefslogtreecommitdiffstats
path: root/doc/html/ntqvaluestack.html
blob: 72cbd490f315bf460def20dbe50ed28127bae509 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/doc/qvaluestack.doc:41 -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>TQValueStack Class</title>
<style type="text/css"><!--
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>TQValueStack Class Reference</h1>

<p>The TQValueStack class is a value-based template class that provides a stack.
<a href="#details">More...</a>
<p>All the functions in this class are <a href="threads.html#reentrant">reentrant</a> when TQt is built with thread support.</p>
<p><tt>#include &lt;<a href="qvaluestack-h.html">ntqvaluestack.h</a>&gt;</tt>
<p>Inherits <a href="ntqvaluelist.html">TQValueList</a>&lt;T&gt;.
<p><a href="qvaluestack-members.html">List of all member functions.</a>
<h2>Public Members</h2>
<ul>
<li class=fn><a href="#TQValueStack"><b>TQValueStack</b></a> ()</li>
<li class=fn><a href="#~TQValueStack"><b>~TQValueStack</b></a> ()</li>
<li class=fn>void <a href="#push"><b>push</b></a> ( const&nbsp;T&nbsp;&amp;&nbsp;d )</li>
<li class=fn>T <a href="#pop"><b>pop</b></a> ()</li>
<li class=fn>T &amp; <a href="#top"><b>top</b></a> ()</li>
<li class=fn>const T &amp; <a href="#top-2"><b>top</b></a> () const</li>
</ul>
<hr><a name="details"></a><h2>Detailed Description</h2>


The TQValueStack class is a value-based template class that provides a stack.
<p> 




<p> Define a template instance TQValueStack&lt;X&gt; to create a stack of
values that all have the class X. TQValueStack is part of the <a href="ntqtl.html">TQt Template Library</a>.
<p> Note that TQValueStack does not store pointers to the members of
the stack; it holds a copy of every member. That is why these
kinds of classes are called "value based"; <a href="ntqptrstack.html">TQPtrStack</a>, <a href="ntqptrlist.html">TQPtrList</a>,
<a href="ntqdict.html">TQDict</a>, etc., are "pointer based".
<p> A stack is a last in, first out (LIFO) structure. Items are added
to the top of the stack with <a href="#push">push</a>() and retrieved from the top
with <a href="#pop">pop</a>(). The <a href="#top">top</a>() function provides access to the topmost item
without removing it.
<p> Example:
<pre>
        TQValueStack&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="ntqvaluelist.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> TQValueStack is a specialized <a href="ntqvaluelist.html">TQValueList</a> provided for convenience.
All of TQValueList's functionality also applies to <a href="ntqptrstack.html">TQPtrStack</a>, for
example the facility to iterate over all elements using
TQValueStack<T>::Iterator. See <a href="qvaluelistiterator.html">TQValueListIterator</a> for further
details.
<p> Some classes cannot be used within a TQValueStack, for example
everything derived from <a href="tqobject.html">TQObject</a> and thus all classes that
implement widgets. Only values can be used in a TQValueStack. To
qualify as a value, the class must 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 and
copy constructors if no explicit version is supplied. In many
cases this is sufficient.
<p>See also <a href="ntqtl.html">TQt 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="TQValueStack"></a>TQValueStack::TQValueStack ()
</h3>

<p> Constructs an empty stack.

<h3 class=fn><a name="~TQValueStack"></a>TQValueStack::~TQValueStack ()
</h3>

<p> Destroys the stack. References to the values in the stack and all
iterators of this stack become invalidated. Because TQValueStack is
highly tuned for performance, you won't see warnings if you use
invalid iterators because it is impossible for an iterator to
check whether or not it is valid.

<h3 class=fn>T <a name="pop"></a>TQValueStack::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>TQValueStack::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="ntqvaluelist.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>TQValueStack::top ()
</h3>

<p> Returns a reference to the top item of the stack or the item
referenced by <a href="ntqvaluelist.html#end">end</a>() if no such item exists. Note that you must not
change the value the end() iterator points to.
<p> This function is equivalent to <a href="ntqvaluelist.html#last">last</a>().
<p> <p>See also <a href="#pop">pop</a>(), <a href="#push">push</a>(), and <a href="ntqvaluelist.html#fromLast">TQValueList::fromLast</a>().

<h3 class=fn>const T &amp; <a name="top-2"></a>TQValueStack::top () const
</h3>

<p> 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 item
referenced by <a href="ntqvaluelist.html#end">end</a>() if no such item exists.
<p> This function is equivalent to <a href="ntqvaluelist.html#last">last</a>().
<p> <p>See also <a href="#pop">pop</a>(), <a href="#push">push</a>(), and <a href="ntqvaluelist.html#fromLast">TQValueList::fromLast</a>().

<!-- eof -->
<hr><p>
This file is part of the <a href="index.html">TQt toolkit</a>.
Copyright &copy; 1995-2007
<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; 2007
<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
<td align=right><div align=right>TQt 3.3.8</div>
</table></div></address></body>
</html>