Pin-Jiun / Programming-Language-CPP

It's the note/experience about C++, and I have the basic ability of C.
0 stars 0 forks source link

15-STL Container stack and queue #19

Open Pin-Jiun opened 1 year ago

Pin-Jiun commented 1 year ago

stack

LIFO stack image 相關function

vector<int> myvector (2,200);  
stack<vector<int> > fourth (myvector);

empty() size() top >> 沒有 front() back() push() pop()


queue

FIFO queue image

創建方式和stack相似

  deque<int> mydeck (3,100);        // deque with 3 elements
  list<int> mylist (2,200);         // list with 2 elements

  queue<int> first;                 // empty queue
  queue<int> second (mydeck);       // queue initialized to copy of deque

  queue<int,list<int> > third; // empty queue with list as underlying container
  queue<int,list<int> > fourth (mylist);

empty() size() front() back() push() pop()