Queue and stack portion

Queue stack and header files commonly used functions and

#include <stack> last out

using namespace std;

stack <type> s (variable);

s.pop () delete the top element

s.empty () determines whether the stack is empty, empty return 1

s.push (i) onto the stack the i

s.top () returns the top element

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

 

#include <queue> FIFO

using namespace std;

queue <type> s;

s.push (i) will be pressed into the queue element i

s.pop () to remove elements of the preceding paragraph, is advanced to the elements

s.size () returns the number of elements in the queue

s.empty () whether the queue is empty, an empty return

s.front () Returns the element in the queue, returns into the first element

 

Priority queue definitions and functions common

#include<queue>

using namespace std;

priority_queue <type> que; // current maximum value that is extracted in descending

priority_queue<int,vector<int>,greater<int> > que2 //升序。,取出来的是当前的最小值 ,注意最后两个尖括号中间要有空格

que.push (i) elements enqueued
que.pop () head of the queue elements dequeue
que.top () take the head of the queue elements
que.empty () if the queue is empty, returns true (1), otherwise it returns false (0 )
que.size () returns the number of elements in the priority queue has

 

Guess you like

Origin www.cnblogs.com/Accepting/p/11210728.html