• <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>

            3D FPS

            1234567890

              C++博客 :: 首頁(yè) :: 聯(lián)系 :: 聚合  :: 管理
              57 Posts :: 2 Stories :: 57 Comments :: 0 Trackbacks

            常用鏈接

            留言簿(10)

            我參與的團(tuán)隊(duì)

            搜索

            •  

            最新評(píng)論

            閱讀排行榜

            評(píng)論排行榜

            C++ 想寫(xiě)些高深的 不過(guò)我不會(huì)
            呀 寫(xiě)些入門(mén)級(jí)的 充充數(shù)
            stl 里面有個(gè)算法的 sort

            大概是用那個(gè)partion sort 算法吧 其實(shí)我不太清楚 根據(jù)OO 思想 不應(yīng)該去知道 對(duì)這個(gè)思想有保流

            使用上方便 放入起始的位置迭代器 然后再放入自己的函數(shù)對(duì)象就可以了

            寫(xiě)個(gè)示例:

            #include <stdio.h>
            #include <tchar.h>
            #include <algorithm>
            #include <iostream>
            #include <utility>
            #include <stdlib.h>
            #include <vector>

            template<int iType>
            struct mygreater
            {     
                bool operator()(const std::pair<int,float>  & _Left, const std::pair<int,float>  & _Right) const
                {   
                    if (iType == 1)
                    {
                        return (_Left.first > _Right.first);
                    }
                    else if (iType == 2)
                    {
                        return (_Left.second > _Right.second);
                    }
                    else
                    {
                         //error
                    }
                   
                }
            };

            void myprint(const std::pair<int,float>  & i)
            {
                std::cout<< i.first << " " << i.second << "\n";
            }

            int _tmain(int argc, _TCHAR* argv[])
            {
                std::vector<std::pair<int,float> > gVecpair;
                for (int i = 0; i <= 10; i++ )
                    gVecpair.push_back( std::make_pair( rand(),(float)rand()));
               
                std::for_each(gVecpair.begin(),gVecpair.end(),myprint);
                std::sort(gVecpair.begin(),gVecpair.end(),mygreater<1>( ));
                std::for_each(gVecpair.begin(),gVecpair.end(),myprint);

                std::cout<<"\n";

                std::sort(gVecpair.begin(),gVecpair.end(),mygreater<2>( ));
                std::for_each(gVecpair.begin(),gVecpair.end(),myprint);

                getchar();
                return 0;
            }


            posted on 2009-01-12 00:12 DK_jims 閱讀(408) 評(píng)論(1)  編輯 收藏 引用 所屬分類(lèi): C++

            Feedback

            # re: stl::sort 2009-01-12 00:20 jimsmorong
            呀 斃 好似有bug  回復(fù)  更多評(píng)論
              

            国产精品久久自在自线观看| 国产成人精品久久综合| 久久精品综合网| 性欧美丰满熟妇XXXX性久久久 | 1000部精品久久久久久久久| 好属妞这里只有精品久久| 91亚洲国产成人久久精品网址| 九九久久精品无码专区| 婷婷国产天堂久久综合五月| 99久久99久久精品免费看蜜桃| 99久久精品费精品国产| 亚洲中文字幕无码久久精品1| 伊人热人久久中文字幕| 亚洲国产成人久久综合一区77| 精品久久久久久成人AV| 中文字幕无码久久人妻| 狠色狠色狠狠色综合久久| 久久久久国产精品嫩草影院| 国产精品永久久久久久久久久| 久久久久久久久久久久中文字幕 | 国内精品久久久久久99蜜桃| 久久久久亚洲AV无码去区首| 国产精品久久久久9999| 蜜臀av性久久久久蜜臀aⅴ麻豆| 久久996热精品xxxx| 久久成人国产精品| 久久久亚洲欧洲日产国码二区| 青青热久久国产久精品 | 精品综合久久久久久98| 欧美成a人片免费看久久| 91麻精品国产91久久久久 | 久久久久久亚洲精品成人| 要久久爱在线免费观看| 日日狠狠久久偷偷色综合96蜜桃| 国产日韩欧美久久| 一本一道久久精品综合| 一本大道加勒比久久综合| 99久久国产免费福利| 久久青青草原国产精品免费 | 久久人人爽人人爽人人片AV东京热 | 中文精品久久久久人妻|