19 #ifndef LIB_QUENTIER_UTILITY_LIMITED_STACK_H
20 #define LIB_QUENTIER_UTILITY_LIMITED_STACK_H
22 #include <quentier/utility/Macros.h>
39 m_limit(-1), m_deleter(deleter)
44 m_limit(other.m_limit),
45 m_deleter(other.m_deleter)
49 QStack<T>(std::move(other)),
50 m_limit(std::move(other.m_limit)),
51 m_deleter(std::move(other.m_deleter))
57 QStack<T>::operator=(other);
58 m_limit = other.m_limit;
59 m_deleter = other.m_deleter;
68 QStack<T>::operator=(std::move(other));
69 m_limit = std::move(other.m_limit);
70 m_deleter = std::move(other.m_deleter);
80 while (!QStack<T>::isEmpty()) {
81 T t = QStack<T>::pop();
89 int limit = other.m_limit;
90 other.m_limit = m_limit;
93 void (*deleter)(T &) = other.m_deleter;
94 other.m_deleter = m_deleter;
97 QStack<T>::swap(other);
100 int limit()
const {
return m_limit; }
101 void setLimit(
const int limit) { m_limit = limit; }
103 void push(
const T & t)
105 if ((m_limit > 0) && (QVector<T>::size() == m_limit - 1)) {
107 (*m_deleter)(*QVector<T>::begin());
109 Q_UNUSED(QVector<T>::erase(QVector<T>::begin()));
117 void (*m_deleter)(T &);
The LimitedStack template class implements a stack which may have a limitation for its size; when the...
Definition: LimitedStack.h:36