C++ queue Library
C++ queue Functions
The <queue> library has functions that let you work with queues. A queue stores elements in FIFO order (First In, First Out). Elements are added at the back, and removed from the front.
A queue has no index numbers and no iterators, so you cannot loop through it like a vector. To read all the elements, read the front element with front(), remove it with pop(), and repeat until the queue is empty.
| Function | Description |
|---|---|
| back() | Returns the last (newest) element of a queue |
| empty() | Checks whether a queue is empty or not |
| front() | Returns the first (oldest) element of a queue |
| pop() | Removes the first (oldest) element of a queue |
| push() | Adds an element to the end (back) of a queue |
| size() | Returns the number of elements in a queue |
| swap() | Swaps the contents of two queues |