• <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>
            posts - 12,  comments - 54,  trackbacks - 0
            昨晚網(wǎng)上搜了一下,沒有找到C++實(shí)現(xiàn)的代碼,于是自己寫了一個(gè);
            無心在這里copy/paste位圖排序的具體解釋,如果有知道得不詳細(xì)的,請?jiān)L問Wikipedia
            ??1?#ifndef?_BITMAP_HPP_INCLUDED
            ??2?#define?_BITMAP_HPP_INCLUDED
            ??3?
            ??4?#include?<cstring>?//for?memset
            ??5?
            ??6?
            ??7?namespace?feng
            ??8?{
            ??9?
            ?10?template<typename?Type>
            ?11?class?Bitmap_Sort
            ?12?{
            ?13?????????typedef?Type?template_type;
            ?14?????private:
            ?15?????????struct?_Bitmap_Impl;
            ?16?????????_Bitmap_Impl*?bi_;
            ?17?????public:
            ?18?????????Bitmap_Sort(?const?template_type&?lower?=?1,?const?template_type&?upper?=?100?)
            ?19?????????{
            ?20?????????bi_?=?lower?<?upper??
            ?21?????????????new?_Bitmap_Impl(lower,upper)?:?
            ?22?????????????new?_Bitmap_Impl(upper,lower);
            ?23?
            ?24?????????}
            ?25?????????~Bitmap_Sort()
            ?26?????????{
            ?27?????????delete?bi_;
            ?28?????????}
            ?29?
            ?30?????????void?process(?const?template_type&?v?)?const
            ?31?????????{
            ?32?????????????(*bi_).register_number(?v?);
            ?33?????????}
            ?34?
            ?35?????????template<typename?Input_Itor>
            ?36?????????void?process(?Input_Itor?begin,?Input_Itor?end?)?const
            ?37?????????{
            ?38?????????while?(?begin?!=?end?)
            ?39?????????????(*bi_).register_number(?*begin++?);
            ?40?????????//including?<algorithm>?is?not?of?necessity
            ?41?????????//for_each(?begin,?end,?&((*bi_).register_number)?);?
            ?42?????????}
            ?43?
            ?44?????????template<typename?Output_Itor>
            ?45?????????Output_Itor?produce(?Output_Itor?begin?)?const
            ?46?????????{
            ?47?????????for?(?Type?i?=?(*bi_).lower_;?i?<=?(*bi_).upper_;?++i?)
            ?48?????????????if?(?(*bi_).query_number(i)?)
            ?49?????????????*begin++?=?i;
            ?50?????????return?begin;
            ?51?????????}
            ?52?};
            ?53?
            ?54?
            ?55?template<typename?Type>
            ?56?struct?Bitmap_Sort<Type>?::?_Bitmap_Impl?
            ?57?{
            ?58?????????typedef?unsigned?long?word_type;
            ?59?????typedef?Type?template_type;
            ?60?
            ?61?????_Bitmap_Impl(?const?template_type&?lower=1,?const?template_type&?upper=100?)
            ?62?????????:?lower_(lower),upper_(upper)
            ?63?????{
            ?64?????????????const?template_type?length?=?upper?-?lower?+?1;
            ?65?????????const?word_type?size?=?(length >> bit_shift())?+?1;?
            ?66?????????
            ?67?????????buffer_?=??new?word_type[size];
            ?68?????????
            ?69?????????memset(buffer_,size,0);
            ?70?????}
            ?71?????~_Bitmap_Impl()
            ?72?????{?
            ?73?????????delete?[]?buffer_;?
            ?74?????}
            ?75?
            ?76?????bool?register_number(?const?template_type&?v?)?const
            ?77?????{
            ?78?????????bool?ans?=?false;
            ?79?????????if?(?v?<=?upper_?&&?v?>=?lower_?)
            ?80?????????{
            ?81?????????????const?template_type?shift?=?v?-?lower_;
            ?82?????????????const?word_type?arr_position?=?shift?>>?bit_shift();
            ?83?????????????const?word_type?relative_position?=?shift?&?(?(1?<<?bit_shift())?-?1?);
            ?84?????????????const?word_type?patch?=?1?<<?(?relative_position?+?1?);
            ?85?????????????buffer_[arr_position]?|=?patch;
            ?86?????????????ans?=?true;
            ?87?????????}
            ?88?????????return?ans;
            ?89?????}
            ?90?????bool?query_number(?const?template_type&?v?)?const
            ?91?????{
            ?92?????????bool?ans?=?false;
            ?93?????????//not?necessory,?commented
            ?94?????????//if?(?v?<=?upper_?&&?v?>=?lower_?)
            ?95?????????//{
            ?96?????????const?template_type?shift?=?v?-?lower_;
            ?97?????????const?word_type?arr_position?=?shift?>>?bit_shift();
            ?98?????????const?word_type?relative_position?=?shift?&?(?(1?<<?bit_shift())?-?1?);
            ?99?????????const?word_type?patch?=?1?<<?(?relative_position?+?1?);
            100?????????if(?buffer_[arr_position]?&?patch?)
            101?????????????ans?=?true;
            102?????????//}
            103?????????return?ans;
            104?????}
            105?
            106?????const?word_type?bit_shift()?const
            107?????{
            108?????????return? 8 == sizeof(unsiged long) ? 6 : 5;
            110?????}
            111?????
            112?????template_type?lower_;
            113?????template_type?upper_;
            114?????mutable?word_type*?buffer_;
            115?};
            116?
            117?
            118?}//namespace?feng
            119?
            120?#endif?//_BITMAP_HPP_INCLUDED
            121?
            122?
            123?


            一個(gè)測試用例:
            #include?<bitmap.hpp>

            #include?
            <iostream>
            #include?
            <iterator>

            using?namespace?std;

            int?main()
            {
            ????feng::Bitmap_Sort
            <unsigned?long>?bs(1,?10000000);
            ????
            //feng::Bitmap_Sort<unsigned?long>?bs(10000000,?1);

            ????bs.process((istream_iterator
            <unsigned?long>(cin)),?(istream_iterator<unsigned?long>()));


            ????bs.produce(ostream_iterator
            <unsigned?long>(cout,?"\n"));


            ????
            return?0;
            }





            posted @ 2009-12-05 12:56 Wang Feng 閱讀(1667) | 評論 (1)編輯 收藏
                 摘要: 影射而已,當(dāng)笑話看看就行:)  閱讀全文
            posted @ 2009-01-11 15:33 Wang Feng 閱讀(606) | 評論 (2)編輯 收藏
                 摘要: 非均勻采樣的數(shù)據(jù)的功率譜估計(jì)方法以及其C++實(shí)現(xiàn)  閱讀全文
            posted @ 2009-01-02 21:20 Wang Feng| 編輯 收藏
                 摘要: 中午的時(shí)候翻到2007年12月24號的kde編譯筆記,不知不覺一年過去了,忽有所感,于是重新編譯一次kde4,記之  閱讀全文
            posted @ 2008-12-18 17:53 Wang Feng 閱讀(591) | 評論 (0)編輯 收藏
                 摘要: 探討了一類因?yàn)橥祿Q概念而產(chǎn)生的悖論。  閱讀全文
            posted @ 2008-11-24 20:15 Wang Feng 閱讀(2283) | 評論 (10)編輯 收藏
                 摘要: 一段覺得比較漂亮的代碼 nth_element  閱讀全文
            posted @ 2008-11-06 16:47 Wang Feng 閱讀(7079) | 評論 (32)編輯 收藏
            請?jiān)?a target="_blank" >這里(http://sourceforge.net/projects/gaplusplus/)下載源代碼。cppblog不支持tar.bz2格式的文檔上傳。

            方才在csdn灌水時(shí),發(fā)現(xiàn)有人給出這個(gè)blog上文章的鏈接,實(shí)在汗顏。
            這邊的blog荒廢了好久,一直沒有動手寫下去;
            前不久把代碼重構(gòu)了一下,放到sf去了;

            如有建議或者疑問,歡迎來信(wanng.fenng[at]gmail.com)討論。

            posted @ 2008-10-28 10:20 Wang Feng 閱讀(1937) | 評論 (1)編輯 收藏
                 摘要: 遺傳算法中,基因變異算法  閱讀全文
            posted @ 2008-06-22 16:20 Wang Feng 閱讀(14339) | 評論 (0)編輯 收藏
                 摘要: 遺傳算法中交叉算法的簡單介紹。可以理解為人類社會的婚姻過程。  閱讀全文
            posted @ 2008-06-18 15:56 Wang Feng 閱讀(12057) | 評論 (1)編輯 收藏
                 摘要: 遺傳算法的數(shù)據(jù)結(jié)構(gòu)定義,以及相關(guān)的幾個(gè)基本算法,c++實(shí)現(xiàn)代碼。  閱讀全文
            posted @ 2008-06-16 16:53 Wang Feng 閱讀(2920) | 評論 (0)編輯 收藏
            僅列出標(biāo)題
            共2頁: 1 2 

            <2025年5月>
            27282930123
            45678910
            11121314151617
            18192021222324
            25262728293031
            1234567

            常用鏈接

            留言簿(4)

            隨筆分類

            隨筆檔案

            Link List

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            精品国产综合区久久久久久 | 日本强好片久久久久久AAA| 一本大道加勒比久久综合| 亚洲欧美日韩久久精品第一区| 99久久综合狠狠综合久久| 人人狠狠综合久久亚洲88| avtt天堂网久久精品| 久久久av波多野一区二区| 国内精品伊人久久久久av一坑| 99久久99久久精品国产片果冻 | 99久久99久久久精品齐齐 | 久久综合色区| 欧美成a人片免费看久久| 日日狠狠久久偷偷色综合96蜜桃| 久久久久国色AV免费观看| 日韩va亚洲va欧美va久久| 久久亚洲2019中文字幕| 久久人妻少妇嫩草AV蜜桃| 三级三级久久三级久久| 久久99国产综合精品女同| 久久99国产精品久久99果冻传媒| 久久国产精品-久久精品| 国产精品美女久久久久av爽| 久久久精品久久久久久| 亚洲精品乱码久久久久久蜜桃| 久久人做人爽一区二区三区 | 久久福利片| 亚洲综合久久夜AV | 久久香蕉超碰97国产精品 | 久久青青草原精品国产不卡| 久久国内免费视频| 99久久久精品| 亚洲国产精品无码久久九九| 久久久亚洲欧洲日产国码二区| 精品久久久久久国产牛牛app| 色综合久久夜色精品国产| 久久久免费精品re6| 中文精品99久久国产 | 99久久久精品免费观看国产| 日日狠狠久久偷偷色综合免费| 国产亚洲综合久久系列|