|
| QStack () = default |
|
| ~QStack () = default |
|
T | pop () |
|
void | push (const T &value) |
|
void | swap (QStack< T > &other) |
|
reference | top () |
|
const_reference | top () const |
|
| QVector () = default |
|
| QVector (const QVector< T > &other) = default |
|
template<class Input_Iterator > |
| QVector (Input_Iterator first, Input_Iterator last) |
|
| QVector (QVector< T > &&other) = default |
|
| QVector (size_type size) |
|
| QVector (size_type size, const T &value) |
|
| QVector (std::initializer_list< T > args) |
|
| ~QVector () = default |
|
void | append (const QVector< T > &other) |
|
void | append (const T &value) |
|
template<typename Iter > |
void | append (Iter begin, Iter end) |
|
void | append (T &&value) |
|
const_reference | at (size_type pos) const |
|
reference | back () |
|
const_reference | back () const |
|
iterator | begin () |
|
const_iterator | begin () const |
|
size_type | capacity () const |
|
const_iterator | cbegin () const |
|
const_iterator | cend () const |
|
void | clear () |
|
const_iterator | constBegin () const |
|
const T * | constData () const |
|
const_iterator | constEnd () const |
|
const_reference | constFirst () const |
|
const_reference | constLast () const |
|
bool | contains (const T &value) const |
|
size_type | count () const |
|
size_type | count (const T &value) const |
|
const_reverse_iterator | crbegin () const |
|
const_reverse_iterator | crend () const |
|
T * | data () |
|
const T * | data () const |
|
bool | empty () const |
|
iterator | end () |
|
const_iterator | end () const |
|
bool | endsWith (const T &value) const |
|
iterator | erase (const_iterator begin, const_iterator end) |
|
iterator | erase (const_iterator pos) |
|
QVector< T > & | fill (const T &value, size_type size=-1) |
|
reference | first () |
|
const_reference | first () const |
|
reference | front () |
|
const_reference | front () const |
|
size_type | indexOf (const T &value, size_type from=0) const |
|
iterator | insert (iterator before, const T &value) |
|
iterator | insert (iterator before, size_type count, const T &value) |
|
template<typename Iter > |
iterator | insert (iterator pos, Iter begin, Iter end) |
|
void | insert (size_type pos, const T &value) |
|
void | insert (size_type pos, size_type count, const T &value) |
|
bool | isEmpty () const |
|
reference | last () |
|
const_reference | last () const |
|
size_type | lastIndexOf (const T &value, size_type from=-1) const |
|
size_type | length () const |
|
QVector< T > | mid (size_type pos, size_type length=-1) const |
|
void | move (size_type from, size_type to) |
|
bool | operator!= (const QVector< T > &other) const |
|
QVector< T > | operator+ (const QVector< T > &other) const |
|
QVector< T > & | operator+= (const QVector< T > &other) |
|
QVector< T > & | operator+= (const T &value) |
|
QVector< T > & | operator<< (const QVector< T > &other) |
|
QVector< T > & | operator<< (const T &value) |
|
QVector< T > & | operator= (const QVector< T > &other) = default |
|
QVector< T > & | operator= (QVector< T > &&other) = default |
|
bool | operator== (const QVector< T > &other) const |
|
reference | operator[] (size_type i) |
|
const_reference | operator[] (size_type i) const |
|
void | pop_back () |
|
void | pop_front () |
|
void | prepend (const T &value) |
|
void | push_back (const T &value) |
|
void | push_back (T &&value) |
|
void | push_front (const T &value) |
|
void | push_front (T &&value) |
|
reverse_iterator | rbegin () |
|
const_reverse_iterator | rbegin () const |
|
void | remove (size_type pos) |
|
void | remove (size_type pos, size_type count) |
|
size_type | removeAll (const T &value) |
|
void | removeAt (size_type pos) |
|
void | removeFirst () |
|
void | removeLast () |
|
bool | removeOne (const T &value) |
|
reverse_iterator | rend () |
|
const_reverse_iterator | rend () const |
|
void | replace (size_type i, const T &value) |
|
void | reserve (size_type size) |
|
void | resize (size_type size) |
|
size_type | size () const |
|
void | squeeze () |
|
bool | startsWith (const T &value) const |
|
void | swap (QVector< T > &other) |
|
T | takeAt (size_type pos) |
|
T | takeFirst () |
|
T | takeLast () |
|
QList< T > | toList () const |
|
std::vector< T > | toStdVector () const |
|
T | value (size_type pos) const |
|
T | value (size_type pos, const T &defaultValue) const |
|
template<class T>
class QStack< T >
The QStack class is a template class which provides a stack. This container implements a stack using a QVector. A stack is a last in, first out (LIFO) data structure. Items are added to the top of the stack using push() and retrieved from the top using pop().
For an overview and comparison of all containers, refer to the documentation for Container Classes. Refer to the section on Time Complexity for a discussion about which operations will be relatively faster or slower for a given container with a size of n.
Basic Operations
QStack inherits from QVector so all of the methods in QVector are available.
The top() method provides access to the topmost element, it does not remove it from the stack. To retrieve the topmost element and also remove it, use pop(). Use the isEmpty() method to determine if the stack has any elements.
To traverse a QStack the QVector iterators can be used.
cout << stack.
pop() << endl;
}
Constraints on type T
The QStack value type T should be Default Constructible and Copy Constructible to work with all methods of this class. Data types like QObject are not copy constructible and therefore should never be stored in a container. You can however use a pointer to a QObject or any subclass as the type T.
- See also
- QVector, QQueue