Queues

Christine_Yang269 total contributions
Published May 23, 2022Updated Dec 21, 2022
Contribute to Docs
Queues are container adaptors that store elements in a first-in-first-out (FIFO) order. Elements inserted into the queue first are removed first.
Syntax
#include <queue>
queue<type> queueName;
type
is the data type that will be stored in the queue.
Codebyte Example
The following codebyte example creates an empty queue, adds elements using the .push()
method, and then prints the elements from the queue:
Queues
- .empty()
- Checks if a queue has no elements.
- .front()
- Returns the next element within the queue.
- .pop()
- Removes the element at the front of the queue.
- .push()
- Adds an element to the back of the queue.
- .size()
- Returns the number of elements in the queue.
All contributors
- Christine_Yang269 total contributions
- garanews209 total contributions
- KyraThompson67 total contributions
Looking to contribute?
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.