简介:先进先出
1.1 是关联式容器,自身是有规则,会进行排序,默认排序升序
1.2 数据结构是二叉树,迭代器是双向
1.3 set容器键值不允许相同
1.4 查找速度很快,有排序需求和查找速度需求,用set容器来存储数据
void test01(){ queue q; q.push(10); q.push(20); q.push(30); q.push(40); q.push(50); cout << q.front() << endl; cout << q.back() << endl; cout << endl; while (!q.empty()) { cout << q.front() << endl; q.pop(); } cout << "size:" << q.size() << endl;}//2.存储对象class Maker{public: Maker(string name, int age) { this->name = name; this->age = age; }public: string name; int age;};void test02(){ queueq; q.push(Maker("aaa1", 10)); q.push(Maker("aaa2", 20)); q.push(Maker("aaa3", 30)); cout << q.front().name<<" "< << endl; cout << q.back().name<<" " < << endl; cout << endl; while (!q.empty()) { cout << q.front().name << " " << q.front().age << endl; q.pop(); } cout << "size:" << q.size() << endl;}int main(){ test02(); system("pause"); return EXIT_SUCCESS;}