STL stack,queue 内部用 deque 实现,可以用一些方式规避掉这个问题。
stack<int,vector<int>>s;
queue<int,list<int>>q;
signed main()
{
q.push(1),q.push(2);
cout<<q.empty()<<'\n';
while(q.size())cout<<q.front()<<'\n',q.pop();
s.push(1),s.push(2);
cout<<s.empty()<<'\n';
while(s.size())cout<<s.top()<<'\n',s.pop();
return 0;
}
标签:deque,定义,STL,queue,push,stack
From: https://www.cnblogs.com/Rainbowsjy/p/16741929.html