• <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++細節深度探索及軟件工程

              C++博客 :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
              37 隨筆 :: 0 文章 :: 74 評論 :: 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 常興龍 閱讀(699) 評論(0)  編輯 收藏 引用
            > hi的博客
            久久久久99精品成人片欧美| 色天使久久综合网天天| 久久精品青青草原伊人| 久久久久久久亚洲Av无码| 国产精品无码久久久久久| 久久午夜无码鲁丝片秋霞| 久久精品国产精品青草| 日本欧美久久久久免费播放网| 青青青青久久精品国产h久久精品五福影院1421| 久久99精品国产麻豆婷婷| 日本久久久精品中文字幕| 久久久久久久久久久久中文字幕 | 99久久人妻无码精品系列蜜桃| 国产精品女同一区二区久久| www.久久精品| 国产精品久久精品| 国产香蕉久久精品综合网| 精品久久人人做人人爽综合| 影音先锋女人AV鲁色资源网久久| 欧美精品乱码99久久蜜桃| 99久久精品费精品国产| 精品水蜜桃久久久久久久| 久久99国产精品尤物| 国产成人综合久久精品红| 国产精品免费久久久久久久久| 久久久av波多野一区二区| 亚洲综合伊人久久综合| 久久久精品久久久久影院| 久久99久久99精品免视看动漫 | 香蕉99久久国产综合精品宅男自| 99国产精品久久| 国产精品久久久久久久久鸭| 亚洲人成网亚洲欧洲无码久久| 久久久久亚洲AV成人网| 久久美女人爽女人爽| 久久99国产综合精品| 99久久国产综合精品麻豆| 国产一级持黄大片99久久| 狠狠色丁香婷婷久久综合不卡| 久久99国产亚洲高清观看首页| 久久超碰97人人做人人爱|