/usr/include/QtCore/qstack.h
Line | Count | Source |
1 | | // Copyright (C) 2016 The Qt Company Ltd. |
2 | | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | | |
4 | | #ifndef QSTACK_H |
5 | | #define QSTACK_H |
6 | | |
7 | | #include <QtCore/qlist.h> |
8 | | |
9 | | QT_BEGIN_NAMESPACE |
10 | | |
11 | | template<class T> |
12 | | class QStack : public QList<T> |
13 | | { |
14 | | public: |
15 | | // compiler-generated special member functions are fine! |
16 | | void swap(QStack<T> &other) noexcept { QList<T>::swap(other); } // prevent QList<->QStack swaps |
17 | 412k | void push(const T &t) { QList<T>::append(t); } |
18 | 33.6k | T pop() { return QList<T>::takeLast(); } |
19 | | T &top() { return QList<T>::last(); } |
20 | | const T &top() const { return QList<T>::last(); } |
21 | | }; |
22 | | |
23 | | QT_END_NAMESPACE |
24 | | |
25 | | #endif // QSTACK_H |