C++ queue and satck usage

In C++, use the header file #include <queue> to use the queue class.

Commonly used functions:

  1. push

  2. pop

  3. size

  4. empty

  5. front

  6. 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! ! !

The usage of deque! ! !



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:

  1. empty() returns true if the stack is empty

  2. pop() remove the top element of the stack

  3. push() adds an element to the top of the stack

  4. size() returns the number of elements in the stack

  5. top() returns the top element of the stack

The stack has no iterators! ! !

Guess you like

Origin blog.csdn.net/weixin_43743711/article/details/114766908