1
<?xml version="1.0" encoding="iso-8859-1"?>
3
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
4
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
<!-- /tmp/qt-4.0.0-espenr-1119621036935/qt-x11-opensource-desktop-4.0.0/doc/src/q3ptrstack.qdoc -->
7
<title>Qt 4.0: Q3PtrStack Class Reference</title>
8
<style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
9
a:link { color: #004faf; text-decoration: none }
10
a:visited { color: #672967; text-decoration: none }
11
td.postheader { font-family: sans-serif }
12
tr.address { font-family: sans-serif }
13
body { background: #ffffff; color: black; }</style>
16
<table border="0" cellpadding="0" cellspacing="0" width="100%">
18
<td align="left" valign="top" width="32"><img src="images/qt-logo.png" align="left" width="32" height="32" border="0" /></td>
19
<td width="1"> </td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a> · <a href="classes.html"><font color="#004faf">All Classes</font></a> · <a href="mainclasses.html"><font color="#004faf">Main Classes</font></a> · <a href="annotated.html"><font color="#004faf">Annotated</font></a> · <a href="groups.html"><font color="#004faf">Grouped Classes</font></a> · <a href="functions.html"><font color="#004faf">Functions</font></a></td>
20
<td align="right" valign="top" width="230"><img src="images/trolltech-logo.png" align="right" width="203" height="32" border="0" /></td></tr></table><h1 align="center">Q3PtrStack Class Reference</h1>
21
<p>The Q3PtrStack class is a template class that provides a stack. <a href="#details">More...</a></p>
22
<pre>#include <Q3PtrStack></pre><p><b>This class is part of the Qt 3 support library.</b> It is provided to keep old source code working. We strongly advise against using it in new code. See the <a href="porting4.html">Porting Guide</a> for more information.</p>
23
<p>Part of the <a href="qt3support.html">Qt3Support</a> module.</p>
24
<p>Inherits <a href="q3ptrcollection.html">Q3PtrCollection</a>.</p>
26
<li><a href="q3ptrstack-members.html">List of all members, including inherited members</a></li>
28
<a name="public-functions"></a>
29
<h3>Public Functions</h3>
31
<li><div class="fn"/><b><a href="q3ptrstack.html#Q3PtrStack">Q3PtrStack</a></b> ()</li>
32
<li><div class="fn"/><b><a href="q3ptrstack.html#Q3PtrStack-2">Q3PtrStack</a></b> ( const Q3PtrStack<type> & <i>s</i> )</li>
33
<li><div class="fn"/><b><a href="q3ptrstack.html#dtor.Q3PtrStack">~Q3PtrStack</a></b> ()</li>
34
<li><div class="fn"/>bool <b><a href="q3ptrstack.html#autoDelete">autoDelete</a></b> () const</li>
35
<li><div class="fn"/>virtual void <b><a href="q3ptrstack.html#clear">clear</a></b> ()</li>
36
<li><div class="fn"/>virtual uint <b><a href="q3ptrstack.html#count">count</a></b> () const</li>
37
<li><div class="fn"/>type * <b><a href="q3ptrstack.html#current">current</a></b> () const</li>
38
<li><div class="fn"/>bool <b><a href="q3ptrstack.html#isEmpty">isEmpty</a></b> () const</li>
39
<li><div class="fn"/>type * <b><a href="q3ptrstack.html#pop">pop</a></b> ()</li>
40
<li><div class="fn"/>void <b><a href="q3ptrstack.html#push">push</a></b> ( const type * <i>d</i> )</li>
41
<li><div class="fn"/>bool <b><a href="q3ptrstack.html#remove">remove</a></b> ()</li>
42
<li><div class="fn"/>void <b><a href="q3ptrstack.html#setAutoDelete">setAutoDelete</a></b> ( bool <i>enable</i> )</li>
43
<li><div class="fn"/>type * <b><a href="q3ptrstack.html#top">top</a></b> () const</li>
44
<li><div class="fn"/><b><a href="q3ptrstack.html#operator-type--2a">operator type *</a></b> () const</li>
45
<li><div class="fn"/>Q3PtrStack<type> & <b><a href="q3ptrstack.html#operator-eq">operator=</a></b> ( const Q3PtrStack<type> & <i>s</i> )</li>
48
<li><div class="fn"/>4 public functions inherited from <a href="q3ptrcollection.html#public-functions">Q3PtrCollection</a></li>
50
<a name="protected-functions"></a>
51
<h3>Protected Functions</h3>
53
<li><div class="fn"/>virtual QDataStream & <b><a href="q3ptrstack.html#read">read</a></b> ( QDataStream & <i>s</i>, Q3PtrCollection::Item & <i>item</i> )</li>
54
<li><div class="fn"/>virtual QDataStream & <b><a href="q3ptrstack.html#write">write</a></b> ( QDataStream & <i>s</i>, Q3PtrCollection::Item <i>item</i> ) const</li>
57
<li><div class="fn"/>2 protected functions inherited from <a href="q3ptrcollection.html#protected-functions">Q3PtrCollection</a></li>
59
<a name="details"></a>
61
<h2>Detailed Description</h2>
62
<p>The Q3PtrStack class is a template class that provides a stack.</p>
63
<p><a href="q3valuestack.html">Q3ValueStack</a> is an STL-compatible alternative to this class.</p>
64
<p>Define a template instance Q3PtrStack<X> to create a stack that operates on pointers to X, (X*).</p>
65
<p>A stack is a last in, first out (LIFO) structure. Items are added to the top of the stack with <a href="q3ptrstack.html#push">push</a>() and retrieved from the top with <a href="q3ptrstack.html#pop">pop</a>(). Use <a href="q3ptrstack.html#top">top</a>() to get a reference to the top element without changing the stack.</p>
66
<p>You can control the stack's deletion policy with <a href="q3ptrstack.html#setAutoDelete">setAutoDelete</a>().</p>
67
<p>For compatibility with the <a href="q3ptrcollection.html">Q3PtrCollection</a> classes <a href="q3ptrstack.html#current">current</a>() and <a href="q3ptrstack.html#remove">remove</a>() are provided; they both operate on the <a href="q3ptrstack.html#top">top</a>().</p>
68
<p>See also <a href="q3ptrlist.html">Q3PtrList</a> and <a href="q3ptrqueue.html">Q3PtrQueue</a>.</p>
70
<h2>Member Function Documentation</h2>
71
<h3 class="fn"><a name="Q3PtrStack"></a>Q3PtrStack::Q3PtrStack ()</h3>
72
<p>Creates an empty stack.</p>
73
<h3 class="fn"><a name="Q3PtrStack-2"></a>Q3PtrStack::Q3PtrStack ( const Q3PtrStack<type> & <i>s</i> )</h3>
74
<p>Creates a stack by making a shallow copy of another stack <i>s</i>.</p>
75
<h3 class="fn"><a name="dtor.Q3PtrStack"></a>Q3PtrStack::~Q3PtrStack ()</h3>
76
<p>Destroys the stack. All items will be deleted if <a href="q3ptrstack.html#autoDelete">autoDelete</a>() is TRUE.</p>
77
<h3 class="fn"><a name="autoDelete"></a>bool Q3PtrStack::autoDelete () const</h3>
78
<p>The same as <a href="q3ptrcollection.html#autoDelete">Q3PtrCollection::autoDelete</a>().</p>
79
<p>See also <a href="q3ptrstack.html#setAutoDelete">setAutoDelete</a>().</p>
80
<h3 class="fn"><a name="clear"></a>void Q3PtrStack::clear () <tt> [virtual]</tt></h3>
81
<p>Removes all items from the stack, deleting them if <a href="q3ptrstack.html#autoDelete">autoDelete</a>() is TRUE.</p>
82
<p>Reimplemented from <a href="q3ptrcollection.html#clear">Q3PtrCollection</a>.</p>
83
<p>See also <a href="q3ptrstack.html#remove">remove</a>().</p>
84
<h3 class="fn"><a name="count"></a><a href="qtglobal.html#uint-typedef">uint</a> Q3PtrStack::count () const <tt> [virtual]</tt></h3>
85
<p>Returns the number of items in the stack.</p>
86
<p>Reimplemented from <a href="q3ptrcollection.html#count">Q3PtrCollection</a>.</p>
87
<p>See also <a href="q3ptrstack.html#isEmpty">isEmpty</a>().</p>
88
<h3 class="fn"><a name="current"></a>type * Q3PtrStack::current () const</h3>
89
<p>Returns a pointer to the top item on the stack (most recently pushed). The stack is not changed. Returns 0 if the stack is empty.</p>
90
<h3 class="fn"><a name="isEmpty"></a>bool Q3PtrStack::isEmpty () const</h3>
91
<p>Returns TRUE if the stack contains no elements; otherwise returns FALSE.</p>
92
<h3 class="fn"><a name="pop"></a>type * Q3PtrStack::pop ()</h3>
93
<p>Removes the top item from the stack and returns it. The stack must not be empty.</p>
94
<h3 class="fn"><a name="push"></a>void Q3PtrStack::push ( const type * <i>d</i> )</h3>
95
<p>Adds an element <i>d</i> to the top of the stack. Last in, first out.</p>
96
<h3 class="fn"><a name="read"></a><a href="qdatastream.html">QDataStream</a> & Q3PtrStack::read ( <a href="qdatastream.html">QDataStream</a> & <i>s</i>, <a href="q3ptrcollection.html#Item-typedef">Q3PtrCollection::Item</a> & <i>item</i> ) <tt> [virtual protected]</tt></h3>
97
<p>Reads a stack item, <i>item</i>, from the stream <i>s</i> and returns a reference to the stream.</p>
98
<p>The default implementation sets <i>item</i> to 0.</p>
99
<p>Reimplemented from <a href="q3glist.html#read-2">Q3GList</a>.</p>
100
<p>See also <a href="q3ptrstack.html#write">write</a>().</p>
101
<h3 class="fn"><a name="remove"></a>bool Q3PtrStack::remove ()</h3>
102
<p>Removes the top item from the stack and deletes it if <a href="q3ptrstack.html#autoDelete">autoDelete</a>() is TRUE. Returns TRUE if there was an item to pop; otherwise returns FALSE.</p>
103
<p>See also <a href="q3ptrstack.html#clear">clear</a>().</p>
104
<h3 class="fn"><a name="setAutoDelete"></a>void Q3PtrStack::setAutoDelete ( bool <i>enable</i> )</h3>
105
<p>Defines whether this stack auto-deletes its contents. The same as <a href="q3ptrcollection.html#setAutoDelete">Q3PtrCollection::setAutoDelete</a>().</p>
106
<p>If <i>enable</i> is TRUE the stack auto-deletes its contents; if <i>enable</i> is FALSE the stack does not delete its contents.</p>
107
<p>See also <a href="q3ptrstack.html#autoDelete">autoDelete</a>().</p>
108
<h3 class="fn"><a name="top"></a>type * Q3PtrStack::top () const</h3>
109
<p>Returns a pointer to the top item on the stack (most recently pushed). The stack is not changed. Returns 0 if the stack is empty.</p>
110
<h3 class="fn"><a name="write"></a><a href="qdatastream.html">QDataStream</a> & Q3PtrStack::write ( <a href="qdatastream.html">QDataStream</a> & <i>s</i>, <a href="q3ptrcollection.html#Item-typedef">Q3PtrCollection::Item</a> <i>item</i> ) const <tt> [virtual protected]</tt></h3>
111
<p>Writes a stack item, <i>item</i>, to the stream <i>s</i> and returns a reference to the stream.</p>
112
<p>The default implementation does nothing.</p>
113
<p>Reimplemented from <a href="q3glist.html#write-2">Q3GList</a>.</p>
114
<p>See also <a href="q3ptrstack.html#read">read</a>().</p>
115
<h3 class="fn"><a name="operator-type--2a"></a>Q3PtrStack::operator type * () const</h3>
116
<p>Returns a pointer to the top item on the stack (most recently pushed). The stack is not changed. Returns 0 if the stack is empty.</p>
117
<h3 class="fn"><a name="operator-eq"></a>Q3PtrStack<type> & Q3PtrStack::operator= ( const Q3PtrStack<type> & <i>s</i> )</h3>
118
<p>Sets the contents of this stack by making a shallow copy of another stack <i>s</i>. Elements currently in this stack will be deleted if <a href="q3ptrstack.html#autoDelete">autoDelete</a>() is TRUE.</p>
119
<p /><address><hr /><div align="center">
120
<table width="100%" cellspacing="0" border="0"><tr class="address">
121
<td width="30%">Copyright © 2005 <a href="trolltech.html">Trolltech</a></td>
122
<td width="40%" align="center"><a href="trademarks.html">Trademarks</a></td>
123
<td width="30%" align="right"><div align="right">Qt 4.0.0</div></td>
124
</tr></table></div></address></body>