/*
//construct queue
queue(const container_type& ctnr = container_type()) ctnr
Container object.
[ctnr是一个容器类对象]
container_type is the type of the underlying container type (defined as an alias of the second class template parameter, Container; see member types).
[ctnr的数据类型container_type是内在容器的数据类型,即第二个模板参数Container] A container adaptor keeps internally a container object as data. This container object is a copy of the ctnr argument passed to the constructor, if any, otherwise it is an empty container.
[queue会将一个容器对象作为数据,这个容器对象是传递到构造函数的参数ctnr,如果没有传递参数ctnr则为空容器]
*/ #include <iostream>
#include <deque>
#include <list>
#include <queue> int main()
{
std::deque<int> mydeck(, );
std::list<int> mylist(, ); std::queue<int> first; // empty queue with deque as underlying container
std::queue<int> second(mydeck); // queue initialized to copy of deque with deque as underlying container std::queue<int, std::list<int>> third; // empty queue with list as underlying container
std::queue<int, std::list<int>> fourth(mylist); // queue initialized to copy of list with list as underlying container std::cout << "size of first: " << first.size() << '\n';
std::cout << "size of second: " << second.size() << '\n';
std::cout << "size of third: " << third.size() << '\n';
std::cout << "size of fourth: " << fourth.size() << '\n'; system("pause");
return ;
}
/*
bool empty() const;
size_type size() const;
void push(const value_type& val);
void pop();
value_type& back();
value_type& front();
*/ #include <iostream>
#include <queue> int main()
{
std::queue<int> myque; for(int i=; i<; i++)
myque.push(i*); std::cout<<"myque contains: ";
while(!myque.empty())
{
std::cout<<myque.front()<<' ';
myque.pop();
} std::cout<<'\n'; system("pause");
return ;
}
05-04 11:30