~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to doc/html/qstack.html

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-08-24 04:09:09 UTC
  • Revision ID: james.westby@ubuntu.com-20050824040909-xmxe9jfr4a0w5671
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version="1.0" encoding="iso-8859-1"?>
 
2
<!DOCTYPE html
 
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/src/corelib/tools/qstack.cpp -->
 
6
<head>
 
7
    <title>Qt 4.0: QStack 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>
 
14
</head>
 
15
<body>
 
16
<table border="0" cellpadding="0" cellspacing="0" width="100%">
 
17
<tr>
 
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">&nbsp;&nbsp;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&nbsp;&middot; <a href="classes.html"><font color="#004faf">All&nbsp;Classes</font></a>&nbsp;&middot; <a href="mainclasses.html"><font color="#004faf">Main&nbsp;Classes</font></a>&nbsp;&middot; <a href="annotated.html"><font color="#004faf">Annotated</font></a>&nbsp;&middot; <a href="groups.html"><font color="#004faf">Grouped&nbsp;Classes</font></a>&nbsp;&middot; <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">QStack Class Reference</h1>
 
21
<p>The QStack class is a template class that provides a stack. <a href="#details">More...</a></p>
 
22
<pre>#include &lt;QStack&gt;</pre><p>Part of the <a href="qtcore.html">QtCore</a> module.</p>
 
23
<p>Inherits <a href="qvector.html">QVector&lt;T&gt;</a>.</p>
 
24
<p><b>Note:</b> All the functions in this class are <a href="threads.html#reentrant">reentrant</a>.</p>
 
25
<ul>
 
26
<li><a href="qstack-members.html">List of all members, including inherited members</a></li>
 
27
</ul>
 
28
<a name="public-functions"></a>
 
29
<h3>Public Functions</h3>
 
30
<ul>
 
31
<li><div class="fn"/><b><a href="qstack.html#QStack">QStack</a></b> ()</li>
 
32
<li><div class="fn"/><b><a href="qstack.html#dtor.QStack">~QStack</a></b> ()</li>
 
33
<li><div class="fn"/>T <b><a href="qstack.html#pop">pop</a></b> ()</li>
 
34
<li><div class="fn"/>void <b><a href="qstack.html#push">push</a></b> ( const T &amp; <i>t</i> )</li>
 
35
<li><div class="fn"/>T &amp; <b><a href="qstack.html#top">top</a></b> ()</li>
 
36
<li><div class="fn"/>const T &amp; <b><a href="qstack.html#top-2">top</a></b> () const</li>
 
37
</ul>
 
38
<ul>
 
39
<li><div class="fn"/>62 public functions inherited from <a href="qvector.html#public-functions">QVector</a></li>
 
40
</ul>
 
41
<h3>Additional Inherited Members</h3>
 
42
<ul>
 
43
<li><div class="fn"/>2 static public members inherited from <a href="qvector.html#static-public-members">QVector</a></li>
 
44
</ul>
 
45
<a name="details"></a>
 
46
<hr />
 
47
<h2>Detailed Description</h2>
 
48
<p>The QStack class is a template class that provides a stack.</p>
 
49
<p>QStack&lt;T&gt; is one of Qt's generic <a href="containers.html#container-classes">container classes</a>. It implements a stack data structure for items of a same type.</p>
 
50
<p>A stack is a last in, first out (LIFO) structure. Items are added to the top of the stack using <a href="qstack.html#push">push</a>() and retrieved from the top using <a href="qstack.html#pop">pop</a>(). The <a href="qstack.html#top">top</a>() function provides access to the topmost item without removing it.</p>
 
51
<p>Example:</p>
 
52
<pre>&nbsp;   QStack&lt;int&gt; stack;
 
53
    stack.push(1);
 
54
    stack.push(2);
 
55
    stack.push(3);
 
56
    while (!stack.isEmpty())
 
57
        cout &lt;&lt; stack.pop() &lt;&lt; endl;</pre>
 
58
<p>The example will output 3, 2, 1 in that order.</p>
 
59
<p>QStack inherits from <a href="qvector.html">QVector</a>. All of <a href="qvector.html">QVector</a>'s functionality also applies to QStack. For example, you can use <a href="qvector.html#isEmpty">isEmpty</a>() to test whether the stack is empty, and you can traverse a QStack using <a href="qvector.html">QVector</a>'s iterator classes (for example, <a href="qvectoriterator.html">QVectorIterator</a>). But in addition, QStack provides three convenience functions that make it easy to implement LIFO semantics: <a href="qstack.html#push">push</a>(), <a href="qstack.html#pop">pop</a>(), and <a href="qstack.html#top">top</a>().</p>
 
60
<p>QStack's value type must be an <a href="containers.html#assignable-data-types">assignable data type</a>. This covers most data types that are commonly used, but the compiler won't let you, for example, store a <a href="qwidget.html">QWidget</a> as a value; instead, store a <a href="qwidget.html">QWidget</a> *.</p>
 
61
<p>See also <a href="qvector.html">QVector</a> and <a href="qqueue.html">QQueue</a>.</p>
 
62
<hr />
 
63
<h2>Member Function Documentation</h2>
 
64
<h3 class="fn"><a name="QStack"></a>QStack::QStack ()</h3>
 
65
<p>Constructs an empty stack.</p>
 
66
<h3 class="fn"><a name="dtor.QStack"></a>QStack::~QStack ()</h3>
 
67
<p>Destroys the stack. References to the values in the stack, and all iterators over this stack, become invalid.</p>
 
68
<h3 class="fn"><a name="pop"></a>T QStack::pop ()</h3>
 
69
<p>Removes the top item from the stack and returns it. This function assumes that the stack isn't empty.</p>
 
70
<p>See also <a href="qstack.html#top">top</a>(), <a href="qstack.html#push">push</a>(), and <a href="qvector.html#isEmpty">isEmpty</a>().</p>
 
71
<h3 class="fn"><a name="push"></a>void QStack::push ( const T &amp; <i>t</i> )</h3>
 
72
<p>Adds element <i>t</i> to the top of the stack.</p>
 
73
<p>This is the same as <a href="qvector.html#append">QVector::append</a>().</p>
 
74
<p>See also <a href="qstack.html#pop">pop</a>() and <a href="qstack.html#top">top</a>().</p>
 
75
<h3 class="fn"><a name="top"></a>T &amp; QStack::top ()</h3>
 
76
<p>Returns a reference to the stack's top item. This function assumes that the stack isn't empty.</p>
 
77
<p>This is the same as <a href="qvector.html#last">QVector::last</a>().</p>
 
78
<p>See also <a href="qstack.html#pop">pop</a>(), <a href="qstack.html#push">push</a>(), and <a href="qvector.html#isEmpty">isEmpty</a>().</p>
 
79
<h3 class="fn"><a name="top-2"></a>const T &amp; QStack::top () const</h3>
 
80
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
81
<p>See also <a href="qstack.html#pop">pop</a>() and <a href="qstack.html#push">push</a>().</p>
 
82
<p /><address><hr /><div align="center">
 
83
<table width="100%" cellspacing="0" border="0"><tr class="address">
 
84
<td width="30%">Copyright &copy; 2005 <a href="trolltech.html">Trolltech</a></td>
 
85
<td width="40%" align="center"><a href="trademarks.html">Trademarks</a></td>
 
86
<td width="30%" align="right"><div align="right">Qt 4.0.0</div></td>
 
87
</tr></table></div></address></body>
 
88
</html>