STL源码解析-04序列容器-04queue&stack

*******************************************
 * queue的实现与stack基本一样,只允许在两端进行操作。
 * 默认情况下,内部的数据是deque。
 * 也可以指定为list。
 * 没有迭代器。
 * *******************************************
 
#include <queue>
#include <iostream>
#include <list>
 
using namespace std;
 
int main()
{
    queue<int, list<int> > q;
    q.push(43);
    return 0;
}
 
******************************************************
 * stack的实现相对简单,只允许在栈顶进行操作。
 * 默认内部的结构是deque。
 * 也可以指定list,vector等。
 * stack是一种适配器,没有迭代器。
 * ***********************************
#include <iostream>
#include <vector>
#include <list>
#include <stack>
 
using namespace std;
 
int main()
{
    stack<int, vector<int> > s;
    s.push(43);
    return 0;
}
posted @ 2011-12-02 15:18  magicdog  阅读(197)  评论(0)    收藏  举报