IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)

QStack Class

The https:// class is a template class that provides a stack.

All functions in this class are https://.

Article lu   fois.

L'auteur

Liens sociaux

Viadeo Twitter Facebook Share on Google+   

QStack Class▲

  • Header: QStack

  • qmake: QT += core

  • Inherits: https://

  • Group: QStack is part of tools, https://

Detailed Description▲

https://<T> is one of Qt's generic https://. It implements a stack data structure for items of a same type.

A stack is a last in, first out (LIFO) structure. Items are added to the top of the stack using push() and retrieved from the top using pop(). The https://() function provides access to the topmost item without removing it.

Example:

 
Sélectionnez
    QStack&lt;int&gt; stack;
    stack.push(1);
    stack.push(2);
    stack.push(3);
    while (!stack.isEmpty())
        cout &lt;&lt; stack.pop() &lt;&lt; endl;

The example will output 3, 2, 1 in that order.

https:// inherits from https://. All of https://'s functionality also applies to https://. For example, you can use https://() to test whether the stack is empty, and you can traverse a https:// using https://'s iterator classes (for example, QVectorIterator). But in addition, https:// provides three convenience functions that make it easy to implement LIFO semantics: push(), pop(), and https://().

https://'s value type must be an https://. This covers most data types that are commonly used, but the compiler won't let you, for example, store a QWidget as a value; instead, store a QWidget *.

See Also▲

See also https://, https://

Member Function Documentation▲

 

[since 4.8] void QStack::swap(QStack<T> &other)▲

Swaps stack other with this stack. This operation is very fast and never fails.

This function was introduced in Qt 4.8.

T &QStack::top()▲

Returns a reference to the stack's top item. This function assumes that the stack isn't empty.

This is the same as https://().

See Also▲

See also pop(), https://, isEmpty()

const T &QStack::top() const▲

This is an overloaded function.

See Also▲

See also pop(), push()

Vous avez aimé ce tutoriel ? Alors partagez-le en cliquant sur les boutons suivants : Viadeo Twitter Facebook Share on Google+   

Ce document est disponible sous la licence https:// telle que publiée par la Free Software Foundation.