• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            C++研究

            C++細(xì)節(jié)深度探索及軟件工程

              C++博客 :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
              37 隨筆 :: 0 文章 :: 74 評(píng)論 :: 0 Trackbacks

            In STL , there are many method can traverse the vector object , but the most efficency one ,I think , it's 'for_each' function. And it can be used very near the real life language , what you need do is only to define a function express how you want to act  while it's traversing.

            E.G

            /********************************************************************
             created: 2007/04/19
             created: 19:4:2007   2:04
             filename:  C:\testvc6\TestStll\TestStll.cpp
             file path: C:\testvc6\TestStll
             file base: TestStll
             file ext: cpp
             author:  Chang xinglong(King.C)
             
             purpose: How to traverse a Vector ?
            *********************************************************************/

             

            You can define a travers Function which simply couput the node data , it was defined  like this :

            void Traverse(int t)
            {
                cout
            <<t<<endl;
            }
            ;

            Then Create a integer vector , and use the for each to travers it ,here the code goes like this:
                vector <int> colt;
                
            for (int i=0; i<=10;i++)
                
            {
                    colt.push_back(i);
                }

                for_each(colt.begin(),colt.end(),Traverse);
                cout
            <<endl;


            Very easy and effiency , try to use it in the program instead of the following code:
            for (int i=0;i<max;i++)
            {
               
            int v =(int) aVector[i];
               traverse(v);
            }
            posted on 2007-04-19 02:18 常興龍 閱讀(701) 評(píng)論(0)  編輯 收藏 引用

            只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。
            網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


            > hi的博客
            久久精品国产精品国产精品污| 99久久无色码中文字幕| 一极黄色视频久久网站| 一本久久a久久精品亚洲| 精品久久一区二区| 色欲综合久久躁天天躁| 精品久久一区二区| 囯产极品美女高潮无套久久久 | 日日躁夜夜躁狠狠久久AV| 国产精品久久一区二区三区| 国产精品99久久久久久宅男小说| 国内精品久久人妻互换 | 亚洲综合久久夜AV | 久久精品国产99国产精偷| 亚洲AV无码久久精品狠狠爱浪潮 | 久久久久亚洲AV无码专区网站| 久久精品国产第一区二区三区| 久久精品国产精品亚洲下载| 91久久婷婷国产综合精品青草| 久久AV无码精品人妻糸列| 久久有码中文字幕| 久久精品亚洲福利| 91精品国产91久久久久久青草| 久久精品国产精品亚洲精品| 欧美无乱码久久久免费午夜一区二区三区中文字幕 | 久久综合九色综合精品| 国产午夜福利精品久久2021| 精品综合久久久久久97| 久久久久久久女国产乱让韩| 日韩久久久久中文字幕人妻| 久久精品不卡| 日韩十八禁一区二区久久| 久久精品国产只有精品66 | 伊人久久亚洲综合影院| 久久www免费人成看片| 午夜精品久久久久久中宇| 亚洲中文久久精品无码| 久久久精品国产sm调教网站 | 久久夜色精品国产亚洲| 久久这里只有精品久久| 久久夜色精品国产|