Home | Projects | Notes > C++ Programming > Container Adaptor - std::queue

Container Adaptor - std::queue

 

std::queue

Initialization

Because std::queue is a container adaptor, you have the flexibility to specify the underlying container—such as deque or list—at the time of queue creation.

Note that std::queue<int, std::vector<int>> q will fail to compile because std::vector lacks pop_front().

Queue Operations

For more information, see cppreference.com.

OperationBehavior
push()Insert an element at the back of the queue.
pop()Remove an element from the front of the queue.
front()Access the element at the front.
back()Access the element at the back.
empty()Is the queue empty?
size()Number of elements in the queue .

 

Project: Usage of std::queue

It's best to adhere to the fundamental operations of a queue. Introducing additional methods like insert() compromises the integrity of the queue's intended behavior.