STL容器方法接口
queue类
1. 初始化队列
queue<string> q1;
queue<string> q2(q1);
queue<double,list<double>> q3;
queue<double,list<double>> q4(q3);
2.bool empty() const;
如果这个队列为空,返回真;否则,返回假
3. unsigned size() const;
返回这个队列对象的项的数量
4. void push(const value_type& x);
将x插入到队列的尾部
平均时间复杂度是常数,最坏时间复杂度是O(n)
这个方法经常被称为“enqueue” 入列
5. const T& front();
返回对这个队列开头项的常量引用
cout<<my_queue.front();
6. void pop();
将位于这个队列开头的项将从这个队列中删除
7. const T& back();
返回对这个队列尾部项的常量引用
对于queue类的所有方法而言,平均时间复杂度都是常数
stack类
1. bool empty();
如果堆栈为空,返回真;否则,返回假
2. unsigned size();
返回这个堆栈中项的数量
3. void push(const T&x);
将x插入到堆栈的顶部
平均时间复杂度为常数,最坏时间复杂度是O(n)
4. const T& top() const;
返回对这个栈顶项的一个常量引用
5. void pop();
移走位于栈顶的项