Queue
The std::queue
follows the FIFO principle (First In First Out). The queue que
, which needs the header <queue>
, has four special methods.
With que.push(e)
you can insert an element e
at the end of the queue and remove the first element from the queue with que.pop()
. que.back()
enables you to refer to the last element in the que
, que.front()
to the first element in the que
. std::queue
has similar characteristics as std::stack
. So you can compare std::queue
instances and get their sizes. The operations of the queue have constant complexity.