
We bake cookies in your browser for a better experience. Using this site means that you consent.Read More
TheQ3PtrStack class is a template class that provides a stack.More...
| Header: | #include <Q3PtrStack> |
| Inherits: | Q3PtrCollection |
| Q3PtrStack() | |
| Q3PtrStack(const Q3PtrStack<type> & s) | |
| ~Q3PtrStack() | |
| bool | autoDelete() const |
| type * | current() const |
| bool | isEmpty() const |
| type * | pop() |
| void | push(const type * d) |
| bool | remove() |
| void | setAutoDelete(bool enable) |
| type * | top() const |
| operator type *() const | |
| Q3PtrStack<type> & | operator=(const Q3PtrStack<type> & s) |
| virtual QDataStream & | read(QDataStream & s, Q3PtrCollection::Item & item) |
| virtual QDataStream & | write(QDataStream & s, Q3PtrCollection::Item item) const |
TheQ3PtrStack class is a template class that provides a stack.
Q3ValueStack is an STL-compatible alternative to this class.
Define a template instanceQ3PtrStack<X> to create a stack that operates on pointers to X, (X*).
A stack is a last in, first out (LIFO) structure. Items are added to the top of the stack withpush() and retrieved from the top withpop(). Usetop() to get a reference to the top element without changing the stack.
You can control the stack's deletion policy withsetAutoDelete().
For compatibility with theQ3PtrCollection classescurrent() andremove() are provided; they both operate on thetop().
See alsoQ3PtrList andQ3PtrQueue.
Creates an empty stack.
Creates a stack by making a shallow copy of another stacks.
Destroys the stack. All items will be deleted ifautoDelete() is true.
The same asQ3PtrCollection::autoDelete(). Returns true if the auto-delete option is set. If the option is set, the stack auto-deletes its contents.
See alsosetAutoDelete().
[virtual]void Q3PtrStack::clear()Reimplemented fromQ3PtrCollection::clear().
Removes all items from the stack, deleting them ifautoDelete() is true.
See alsoremove().
[virtual]uint Q3PtrStack::count() constReimplemented fromQ3PtrCollection::count().
Returns the number of items in the stack.
See alsoisEmpty().
Returns a pointer to the top item on the stack (most recently pushed). The stack is not changed. Returns 0 if the stack is empty.
Returns true if the stack contains no elements; otherwise returns false.
Removes the top item from the stack and returns it. The stack must not be empty.
Adds an elementd to the top of the stack. Last in, first out.
[virtual protected]QDataStream & Q3PtrStack::read(QDataStream & s,Q3PtrCollection::Item & item)Reads a stack item,item, from the streams and returns a reference to the stream.
The default implementation setsitem to 0.
See alsowrite().
Removes the top item from the stack and deletes it ifautoDelete() is true. Returns true if there was an item to pop; otherwise returns false.
See alsoclear().
Defines whether this stack auto-deletes its contents. The same asQ3PtrCollection::setAutoDelete(). Ifenable is true, auto-delete is turned on.
If auto-deleting is turned on, all the items in the stack are deleted when the stack itself is deleted. This is convenient if the stack has the only pointers to the items.
The default setting is false, for safety. If you turn it on, be careful about copying the stack, or you might find yourself with two stacks deleting the same items.
Note that the auto-delete setting may also affect other functions in subclasses. For example, a subclass that has aremove() function will remove the item from its data structure, and if auto-delete is enabled, will also delete the item.
See alsoautoDelete().
Returns a pointer to the top item on the stack (most recently pushed). The stack is not changed. Returns 0 if the stack is empty.
[virtual protected]QDataStream & Q3PtrStack::write(QDataStream & s,Q3PtrCollection::Item item) constWrites a stack item,item, to the streams and returns a reference to the stream.
The default implementation does nothing.
See alsoread().
Returns a pointer to the top item on the stack (most recently pushed). The stack is not changed. Returns 0 if the stack is empty.
Sets the contents of this stack by making a shallow copy of another stacks. Elements currently in this stack will be deleted ifautoDelete() is true.
© 2016 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of theGNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.