QQueue Class
template <typename T> class QQueue
The QQueue class is a template class that provides a queue. More…
| Header | #include <QQueue> |
|---|---|
| CMake | target_link_libraries(app PRIVATE Nt::Core) |
| Module | Nt Core C++ Classes |
| Inherits | QList |
List of all members, including inherited members
Public Functions
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
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().
T & QQueue::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.