In C++, use the header file #include <queue> to use the queue class.
Commonly used functions:
-
push
-
pop
-
size
-
empty
-
front
-
back
(The bottom layer of the queue uses deque, so the queue is just calling the interface of deque, but a layer of encapsulation is added to restrict some functions)
The queue has no iterators! ! !
C++ Stack (stack) is an adaptation of a container class that provides programmers with all the functions of the stack, that is to say, implements a first-in-last-out (FILO) data structure.
The header file of c++ stl stack stack is:
#include < stack >
C++ stl stack member function introduction:
-
empty() returns true if the stack is empty
-
pop() remove the top element of the stack
-
push() adds an element to the top of the stack
-
size() returns the number of elements in the stack
-
top() returns the top element of the stack
The stack has no iterators! ! !