QStack<T>
is a template Qt class providing stack. Its analogue in STL is std::stack
. It is last in, first out structure (LIFO).
QStack<QString> stack;
stack.push("First");
stack.push("Second");
stack.push("Third");
while (!stack.isEmpty())
{
cout << stack.pop() << endl;
}
It will output: Third, Second, First.
QStack
inherits from QVector
so its implementation is quite different from STL. In STL std::stack
is implemented as a wrapper to type passed as a template argument (deque by default). Still main operations are the same for QStack
and for std::stack
.