Advertisement
LEGEND2004

stack , queue , deque , priority_queue

Feb 26th, 2024
929
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.70 KB | None | 0 0
  1. stack<int> s;
  2.     s.size();
  3.     s.empty();
  4.     s.push(x);
  5.     s.top();
  6.     s.pop();
  7.  
  8.  
  9.     queue<int> q;
  10.     q.size();
  11.     q.empty();
  12.     q.push(x);
  13.     q.front();
  14.     q.pop();
  15.    
  16.     deque<int> q;
  17.     q.size();
  18.     q.empty();
  19.     int x;
  20.     q.push_back(x);
  21.     q.pop_back();
  22.     q.back();
  23.    
  24.     q.push_front(x);
  25.     q.pop_front();
  26.     q.front();
  27.    
  28.     priority_queue<int> q;
  29.     q.size();
  30.     q.empty();
  31.     int x;
  32.     q.push(x);
  33.     q.top(); // max element in pq
  34.     q.pop(); // delete max
  35.  
  36.     priority_queue<int , vector<int> , greater<int> > q;
  37.     q.size();
  38.     q.empty();
  39.     int x;
  40.     q.push(x);
  41.     q.top(); // min element in pq
  42.     q.pop(); // delete min
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement