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
|
'\" t
.TH QValueStack 3qt "2 February 2007" "Trolltech AS" \" -*- nroff -*-
.\" Copyright 1992-2007 Trolltech ASA. All rights reserved. See the
.\" license file included in the distribution for a complete license
.\" statement.
.\"
.ad l
.nh
.SH NAME
QValueStack \- Value-based template class that provides a stack
.SH SYNOPSIS
All the functions in this class are reentrant when Qt is built with thread support.</p>
.PP
\fC#include <qvaluestack.h>\fR
.PP
Inherits QValueList<T>.
.PP
.SS "Public Members"
.in +1c
.ti -1c
.BI "\fBQValueStack\fR ()"
.br
.ti -1c
.BI "\fB~QValueStack\fR ()"
.br
.ti -1c
.BI "void \fBpush\fR ( const T & d )"
.br
.ti -1c
.BI "T \fBpop\fR ()"
.br
.ti -1c
.BI "T & \fBtop\fR ()"
.br
.ti -1c
.BI "const T & \fBtop\fR () const"
.br
.in -1c
.SH DESCRIPTION
The QValueStack class is a value-based template class that provides a stack.
.PP
Define a template instance QValueStack<X> to create a stack of values that all have the class X. QValueStack is part of the Qt Template Library.
.PP
Note that QValueStack 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"; QPtrStack, QPtrList, QDict, etc., are "pointer based".
.PP
A stack is a last in, first out (LIFO) structure. Items are added to the top of the stack with push() and retrieved from the top with pop(). The top() function provides access to the topmost item without removing it.
.PP
Example:
.PP
.nf
.br
QValueStack<int> stack;
.br
stack.push( 1 );
.br
stack.push( 2 );
.br
stack.push( 3 );
.br
while ( ! stack.isEmpty() )
.br
cout << "Item: " << stack.pop() << endl;
.br
.br
// Output:
.br
// Item: 3
.br
// Item: 2
.br
// Item: 1
.br
.fi
.PP
QValueStack is a specialized QValueList provided for convenience. All of QValueList's functionality also applies to QPtrStack, for example the facility to iterate over all elements using QValueStack<T>::Iterator. See QValueListIterator for further details.
.PP
Some classes cannot be used within a QValueStack, for example everything derived from QObject and thus all classes that implement widgets. Only values can be used in a QValueStack. To qualify as a value, the class must provide
.TP
a copy constructor;
.TP
an assignment operator;
.TP
a default constructor, i.e. a constructor that does not take any arguments.
.PP
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.
.PP
See also Qt Template Library Classes, Implicitly and Explicitly Shared Classes, and Non-GUI Classes.
.SH MEMBER FUNCTION DOCUMENTATION
.SH "QValueStack::QValueStack ()"
Constructs an empty stack.
.SH "QValueStack::~QValueStack ()"
Destroys the stack. References to the values in the stack and all iterators of this stack become invalidated. Because QValueStack 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.
.SH "T QValueStack::pop ()"
Removes the top item from the stack and returns it.
.PP
See also top() and push().
.SH "void QValueStack::push ( const T & d )"
Adds element, \fId\fR, to the top of the stack. Last in, first out.
.PP
This function is equivalent to append().
.PP
See also pop() and top().
.SH "T & QValueStack::top ()"
Returns a reference to the top item of the stack or the item referenced by end() if no such item exists. Note that you must not change the value the end() iterator points to.
.PP
This function is equivalent to last().
.PP
See also pop(), push(), and QValueList::fromLast().
.SH "const T & QValueStack::top () const"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Returns a reference to the top item of the stack or the item referenced by end() if no such item exists.
.PP
This function is equivalent to last().
.PP
See also pop(), push(), and QValueList::fromLast().
.SH "SEE ALSO"
.BR http://doc.trolltech.com/qvaluestack.html
.BR http://www.trolltech.com/faq/tech.html
.SH COPYRIGHT
Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com. See the
license file included in the distribution for a complete license
statement.
.SH AUTHOR
Generated automatically from the source code.
.SH BUGS
If you find a bug in Qt, please report it as described in
.BR http://doc.trolltech.com/bughowto.html .
Good bug reports help us to help you. Thank you.
.P
The definitive Qt documentation is provided in HTML format; it is
located at $QTDIR/doc/html and can be read using Qt Assistant or with
a web browser. This man page is provided as a convenience for those
users who prefer man pages, although this format is not officially
supported by Trolltech.
.P
If you find errors in this manual page, please report them to
.BR qt-bugs@trolltech.com .
Please include the name of the manual page (qvaluestack.3qt) and the Qt
version (3.3.8).
|