C + + STL stack and queue

Time:2021-5-8

Stack and queue

Header file

#Include // queue 
#Include // stack

Definition method

//Parameters are data types
stack s; 
queue q;

Common operations

//Stack operation:
s. Empty() // is the element empty
s. Size() // returns the number of elements in the stack  
s. Pop() // delete the top of stack element without returning its value  
s. Top() // returns the element at the top of the stack without deleting it  
s. Push (x) // push a new element at the top of the stack  , Parameter x is the element to be pressed in

Stack

//Queue operation:
q. Empty() // is the element empty
q. Size() // returns the number of elements in the queue  
q. Pop() // delete the first element of the queue without returning its value  
q. Front() // returns the value of the team leader element, but does not delete the element  
q. Push (x) // press in new elements at the end of the team. X is the element to be pushed in
q. Back() // returns the value of the element at the end of the queue, but does not delete the element

queue