6.0.0-rc4Source

QQueue Class

template <typename T> class QQueue

The QQueue class is a template class that provides a queue. More…

Header#include <QQueue>
CMaketarget_link_libraries(app PRIVATE Nt::Core)
ModuleNt Core C++ Classes
InheritsQList

List of all members, including inherited members

Public Functions

voidenqueue(const T &t)
Tdequeue()
T &head()
const T &head() const

Detailed Description

QQueue<T> is a QList<T> with first-in, first-out operations: items are added with enqueue() and taken from the front with dequeue(). All of QList's functions are available.

QQueue<int> queue;
queue.enqueue(1);
queue.enqueue(2);
int first = queue.dequeue(); // 1

See also QList and QStack.

Differences from Qt

The class is a plain subclass of QList that adds only enqueue(), dequeue() and head(). It has no further members.

Member Function Documentation

T QQueue::dequeue()

Removes the head item in the queue and returns it. The queue must not be empty.

See also enqueue() and head().

void QQueue::enqueue(const T &t)

Adds t to the end of the queue.

See also dequeue() and head().

Returns a reference to the item at the head of the queue. The queue must not be empty.

See also enqueue() and dequeue().

const T & QQueue::head() const

This is an overloaded function.

Returns a const reference to the item at the head of the queue.