• deque-clear


    ////////////////////////////////////////
    //      2018/04/23 14:36:07
    //      deque-clear
    #include <iostream>
    #include <deque>
    #include <algorithm>
    
    using namespace std;
    
    template<class T>
    class Print
    {
    public:
        void operator()(T& t){
            cout << t << " ";
        }
    };
    
    //==============================
    
    int main(){
        deque<int> d(10);
        Print<int> print;
        fill(d.begin(), d.end(), 5);
    
        cout << "Deque d:";
        for_each(d.begin(),d.end(), print);
        cout << endl;
        cout << "Size of d = " << d.size() << endl;
    
        cout << "d.clear()" << endl;
        d.clear();
    
        cout << "Deque d:";
        for_each(d.begin(), d.end(), print);
        cout << endl;
        cout << "Size of d = " << d.size() << endl;
    
        cout << "Deque d is";
        d.empty() ? cout << "" : cout << "not";
        cout << "empty" << endl;
    
        return 0;
    }
    
    
    /*
    OUTPUT:
        Deque d:5 5 5 5 5 5 5 5 5 5
        Size of d = 10
        d.clear()
        Deque d:
        Size of d = 0
        Deque d isempty
    */
  • 相关阅读:
    Java-笔记9-复习
    Java-笔记9
    Java-笔记8-复习
    Java0-笔记8
    Java-笔记7-复习
    hadoop-hdfs-ha配置-搭建
    Java-笔记7
    Java-笔记6-复习
    kettle-作业和参数
    kettle-脚本控件
  • 原文地址:https://www.cnblogs.com/laohaozi/p/12538007.html
Copyright © 2020-2023  润新知