File: qvaluestack.html

package info (click to toggle)
qt-x11 3%3A2.3.1-22
  • links: PTS
  • area: main
  • in suites: woody
  • size: 48,524 kB
  • ctags: 46,337
  • sloc: cpp: 260,077; ansic: 32,457; makefile: 31,131; yacc: 2,444; sh: 1,513; lex: 480; perl: 422; xml: 68; lisp: 15
file content (129 lines) | stat: -rw-r--r-- 6,687 bytes parent folder | download | duplicates (2)
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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Qt Toolkit - QValueStack Class</title><style type="text/css"><!--
h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }body { background: white; color: black; }
--></style>
</head><body bgcolor="#ffffff">

<table width="100%">
<tr><td><a href="index.html">
<img width="100" height="100" src="qtlogo.png"
alt="Home" border="0"><img width="100"
height="100" src="face.png" alt="Home" border="0">
</a><td valign=top><div align=right><img src="dochead.png" width="472" height="27"><br>
<a href="classes.html"><b>Classes</b></a>
-<a href="annotated.html">Annotated</a>
- <a href="hierarchy.html">Tree</a>
-<a href="functions.html">Functions</a>
-<a href="index.html">Home</a>
-<a href="topicals.html"><b>Structure</b></a>
</div>
</table>

<h1 align=center>QValueStack Class Reference</h1><br clear="all">
<p>
The QValueStack class is a value based template class that provides a stack.
<a href="#details">More...</a>
<p>
<code>#include &lt;<a href="qvaluestack-h.html">qvaluestack.h</a>&gt;</code>
<p>
Inherits <a href="qvaluelist.html">QValueList</a>.
<p><a href="qvaluestack-members.html">List of all member functions.</a>
<h2>Public Members</h2>
<ul>
<li><div class="fn"><a href="#da9a46"><b>QValueStack</b></a>()</div>
<li><div class="fn"><a href="#97caf6"><b>~QValueStack</b></a>()</div>
<li><div class="fn">void<a href="#d87884"><b>push</b></a>(constT&amp;d)</div>
<li><div class="fn">T<a href="#bc1ba4"><b>pop</b></a>()</div>
<li><div class="fn">T&amp;<a href="#7618e8"><b>top</b></a>()</div>
<li><div class="fn">constT&amp;<a href="#0d2eb4"><b>top</b></a>()const</div>
</ul>
<hr><h2><a name="details"></a>Detailed Description</h2>
The QValueStack class is a value based template class that provides a stack.
<p>
Define a template instance QValueStack&lt;X&gt; to create a stack of values which all
have the class X. Please notice that QValueStack does not store pointers to the
members of the stack. It holds a copy of every member. That is the reason why this
kind of classes are called "value based" while <a href="qstack.html">QStack</a>, <a href="qlist.html">QList</a> and <a href="qdict.html">QDict</a> are "reference based".
<p>A stack is a Last In, First Out (LIFO) structure. Items are added to
the top of the stack with <a href="#d87884">push</a>() and retrieved from the top with
<a href="#bc1ba4">pop</a>(). Furthermore, <a href="#0d2eb4">top</a>() provides access to the topmost item
without removing it.
<p>Example:
<pre>    #include &lt;qvaluestack.h&gt;
    #include &lt;stdio.h&gt;

    void main()
    {
        <a href="qvaluestack.html">QValueStack</a>&lt;int&gt; stack;
        stack.<a href="#d87884">push</a>( 1 );
        stack.<a href="#d87884">push</a>( 2 );
        stack.<a href="#d87884">push</a>( 3 );
        while ( !stack.isEmpty() )
                printf("pop item %d\n", stack.<a href="#bc1ba4">pop</a>() );
  }
</pre>
<p>Program output:
<pre>        pop item 3;
        pop item 2;
        pop item 1;
</pre>
<p>Technically, QValueStack is a specialized <a href="qvaluelist.html">QValueList</a> provided for
convenience. All of QValueList's functionality applies also to
QStack, for example the facility to iterate over all elements using
QValueStack<T>::Iterator. See <a href="qvaluelistiterator.html">QValueListIterator</a> for further details.
<p>Some classes can not be used within a QValueStack, for example everything
derived from <a href="qobject.html">QObject</a> and thus all classes that implement widgets.
Only values can be used in a QValueStack. To qualify as a value, the class
must provide
<ul>
<li>a copy constructor,
<li>an assignment operator and
<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.

<hr><h2>Member Function Documentation</h2>
<h3 class="fn"><a name="da9a46"></a>QValueStack::QValueStack()</h3>
<p>Constructs an empty stack.
<h3 class="fn"><a name="97caf6"></a>QValueStack::~QValueStack()</h3>
<p>Destroys the stack. References to the values in the stack and all iterators
of this stack become invalidated. Since QValueStack is highly tuned for performance
you wont see warnings if you use invalid iterators,
because it is impossible for an iterator to check wether it is valid or not.
<h3 class="fn">T<a name="bc1ba4"></a>QValueStack::pop()</h3>
<p>Removes the top item from the stack and returns it.
<p>See also  <a href="#0d2eb4">top</a>() and <a href="#d87884">push</a>().
<h3 class="fn">void<a name="d87884"></a>QValueStack::push(constT&amp;d)</h3>
<p>Adds an element to the top of the stack.  Last in, first out.
<p>This function is equivalent to append()
<p>See also  <a href="#bc1ba4">pop</a>() and <a href="#0d2eb4">top</a>().
<h3 class="fn">T&amp;<a name="7618e8"></a>QValueStack::top()</h3>
<p>Returns a reference to the top item of the stack or the item
referenced by end() if no
such item exists. Please note that you may not change
the value the end() Iterator is pointing to.
<p>This function is equivalent to last().
<p>See also  <a href="#bc1ba4">pop</a>(), <a href="#d87884">push</a>() and <a href="qvaluelist.html#77bdf7">QValueList::fromLast</a>().
<h3 class="fn">constT&amp;<a name="0d2eb4"></a>QValueStack::top()const</h3>
<p>Returns a reference to the top item of the stack or the item
referenced by end() if no such item exists.
<p>This function is equivalent to last().
<p>See also  <a href="#bc1ba4">pop</a>(), <a href="#d87884">push</a>() and <a href="qvaluelist.html#77bdf7">QValueList::fromLast</a>().
<hr><p>
Search the documentation, FAQ, qt-interest archive and more (uses
<a href="http://www.trolltech.com">www.trolltech.com</a>):<br>
<form method=post action="http://www.trolltech.com/search.cgi">
<input type=hidden name="version" value="2.3.1"><nobr>
<input size="50" name="search"><input type=submit value="Search">
</nobr></form><hr><p>
This file is part of the <a href="index.html">Qt toolkit</a>,
copyright &copy; 1995-2000
<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  2000 Trolltech<td><a href="http://www.trolltech.com/trademarks.html">Trademarks</a>
<td align="right"><div align="right">Qt version 2.3.1</div>
</table></div></address></body></html>