make QStack::pop() call QVector::last()

Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
This commit is contained in:
Ivailo Monev 2016-11-05 22:12:23 +00:00
parent d182b91452
commit 26ab0edab0

View file

@ -57,9 +57,9 @@ public:
inline ~QStack() {}
inline void swap(QStack<T> &other) { QVector<T>::swap(other); } // prevent QVector<->QStack swaps
inline void push(const T &t) { QVector<T>::append(t); }
T pop();
T &top();
const T &top() const;
inline T pop();
inline T &top() { return QVector<T>::last(); }; // for compatibility
const T &top() const { return QVector<T>::last(); }; // for compatibility
};
template<class T>
@ -67,14 +67,6 @@ inline T QStack<T>::pop()
{ Q_ASSERT(!this->isEmpty()); T t = this->data()[this->size() -1];
this->resize(this->size()-1); return t; }
template<class T>
inline T &QStack<T>::top()
{ Q_ASSERT(!this->isEmpty()); this->detach(); return this->data()[this->size()-1]; }
template<class T>
inline const T &QStack<T>::top() const
{ Q_ASSERT(!this->isEmpty()); return this->data()[this->size()-1]; }
QT_END_NAMESPACE
QT_END_HEADER