Warning: That file was not part of the compilation database. It may have many parsing errors.
1 | /**************************************************************************** |
---|---|
2 | ** |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
4 | ** Contact: https://www.qt.io/licensing/ |
5 | ** |
6 | ** This file is part of the QtCore module of the Qt Toolkit. |
7 | ** |
8 | ** $QT_BEGIN_LICENSE:LGPL$ |
9 | ** Commercial License Usage |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
11 | ** accordance with the commercial license agreement provided with the |
12 | ** Software or, alternatively, in accordance with the terms contained in |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
15 | ** information use the contact form at https://www.qt.io/contact-us. |
16 | ** |
17 | ** GNU Lesser General Public License Usage |
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser |
19 | ** General Public License version 3 as published by the Free Software |
20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the |
21 | ** packaging of this file. Please review the following information to |
22 | ** ensure the GNU Lesser General Public License version 3 requirements |
23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. |
24 | ** |
25 | ** GNU General Public License Usage |
26 | ** Alternatively, this file may be used under the terms of the GNU |
27 | ** General Public License version 2.0 or (at your option) the GNU General |
28 | ** Public license version 3 or any later version approved by the KDE Free |
29 | ** Qt Foundation. The licenses are as published by the Free Software |
30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 |
31 | ** included in the packaging of this file. Please review the following |
32 | ** information to ensure the GNU General Public License requirements will |
33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and |
34 | ** https://www.gnu.org/licenses/gpl-3.0.html. |
35 | ** |
36 | ** $QT_END_LICENSE$ |
37 | ** |
38 | ****************************************************************************/ |
39 | |
40 | /*! |
41 | \class QStack |
42 | \inmodule QtCore |
43 | \brief The QStack class is a template class that provides a stack. |
44 | |
45 | \ingroup tools |
46 | \ingroup shared |
47 | |
48 | \reentrant |
49 | |
50 | QStack\<T\> is one of Qt's generic \l{container classes}. It implements |
51 | a stack data structure for items of a same type. |
52 | |
53 | A stack is a last in, first out (LIFO) structure. Items are added |
54 | to the top of the stack using push() and retrieved from the top |
55 | using pop(). The top() function provides access to the topmost |
56 | item without removing it. |
57 | |
58 | Example: |
59 | |
60 | \snippet qstack/main.cpp 0 |
61 | |
62 | The example will output 3, 2, 1 in that order. |
63 | |
64 | QStack inherits from QVector. All of QVector's functionality also |
65 | applies to QStack. For example, you can use isEmpty() to test |
66 | whether the stack is empty, and you can traverse a QStack using |
67 | QVector's iterator classes (for example, QVectorIterator). But in |
68 | addition, QStack provides three convenience functions that make |
69 | it easy to implement LIFO semantics: push(), pop(), and top(). |
70 | |
71 | QStack's value type must be an \l{assignable data type}. This |
72 | covers most data types that are commonly used, but the compiler |
73 | won't let you, for example, store a QWidget as a value; instead, |
74 | store a QWidget *. |
75 | |
76 | \sa QVector, QQueue |
77 | */ |
78 | |
79 | /*! |
80 | \fn template<class T> void QStack<T>::swap(QStack<T> &other) |
81 | \since 4.8 |
82 | |
83 | Swaps stack \a other with this stack. This operation is very fast and |
84 | never fails. |
85 | */ |
86 | |
87 | /*! |
88 | \fn template<class T> void QStack<T>::push(const T& t) |
89 | |
90 | Adds element \a t to the top of the stack. |
91 | |
92 | This is the same as QVector::append(). |
93 | |
94 | \sa pop(), top() |
95 | */ |
96 | |
97 | /*! |
98 | \fn template<class T> T& QStack<T>::top() |
99 | |
100 | Returns a reference to the stack's top item. This function |
101 | assumes that the stack isn't empty. |
102 | |
103 | This is the same as QVector::last(). |
104 | |
105 | \sa pop(), push(), isEmpty() |
106 | */ |
107 | |
108 | /*! |
109 | \fn template<class T> const T& QStack<T>::top() const |
110 | |
111 | \overload |
112 | |
113 | \sa pop(), push() |
114 | */ |
115 | |
116 | /*! |
117 | \fn template<class T> T QStack<T>::pop() |
118 | |
119 | Removes the top item from the stack and returns it. This function |
120 | assumes that the stack isn't empty. |
121 | |
122 | \sa top(), push(), isEmpty() |
123 | */ |
124 |
Warning: That file was not part of the compilation database. It may have many parsing errors.