... uses stack
function top
to retrieve the top element of the stack
for output. Line 56 uses function pop
(available in each adapter class) to remove the top element of the stack
. Function pop
does not return a value.
15.7.2 queue
Adapter
A queue is similar to a waiting line. The item that has been in the queue the longest is the next one removed—so a queue is referred to as a first-in, first-out (FIFO) data structure. Class queue
(from header <queue>
) enables insertions only at the back of the underlying data structure and deletions only from the front. A queue
can store its elements in objects of the Standard Library’s list
or deque
containers. By default, a queue
is implemented with a deque
. The common queue
operations are push
to insert an element ...
Get C++ How to Program, 10/e now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.