⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 chapter5-12.cpp

📁 STL程序员开发指南源码
💻 CPP
字号:
//文件名:CHAPTER5-12.cpp
#include <list>
#include <iostream>
#include <queue>
#include <deque>
using namespace std ;
// 通过list使用queue 
typedef list<int > INTLIST;
typedef queue<int>  INTQUEUE;
//通过deque使用queue 
typedef deque<char*> CHARDEQUE;
typedef queue<char*> CHARQUEUE;
void main(void)
{
    int size_q;
    INTQUEUE q;
    CHARQUEUE p;
    // Insert items in the queue(uses list)
    q.push(42);
    q.push(100);
    q.push(49);
    q.push(201);
    // Output the size of queue
    size_q = q.size();
    cout << "size of q is:" << size_q << endl;
    // Output items in queue using front()
    // and use pop() to get to next item until
    // queue is empty
    while (!q.empty())    {    cout << q.front() << endl;   q.pop();   }
// Insert items in the queue(uses deque)
    p.push("cat");
    p.push("ape");
    p.push("dog");
    p.push("mouse");
    p.push("horse");
    // Output the item inserted last using back()
    cout << p.back() << endl;
    // Output the size of queue
    size_q = p.size();
    cout << "size of p is:" << size_q << endl;
    // Output items in queue using front()
    // and use pop() to get to next item until
    // queue is empty
    while (!p.empty())  {  cout << p.front() << endl;  p.pop(); }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -