• <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>
            隨筆 - 15  文章 - 5  trackbacks - 0
            <2011年9月>
            28293031123
            45678910
            11121314151617
            18192021222324
            2526272829301
            2345678

            常用鏈接

            留言簿

            隨筆分類

            隨筆檔案

            文章分類

            文章檔案

            搜索

            •  

            最新評(píng)論

            • 1.?re: 2011年9月26日[未登錄](méi)
            • 我不是吹噓,為什么1,2,3,4,5,7,9,10,11,12我都知道一點(diǎn)????
              看來(lái)我估計(jì)可以過(guò)電面啊~_~
            • --ZJ
            • 2.?re: 2011年9月26日
            • 有計(jì)劃的人生會(huì)很精彩。。
            • --Cheap glueless lace front wigs
            • 3.?re: 2011年9月26日
            • (14)舉個(gè)例子說(shuō)明你學(xué)習(xí)能力比較強(qiáng),
              牛!

              那個(gè)騰訊就是做QQ的吧,QQ里面還內(nèi)嵌個(gè)木馬,有事沒(méi)事的掃描下用戶磁盤(pán),唉,公司技術(shù)就這鳥(niǎo)水平,還對(duì)應(yīng)聘者提那么多要求。
            • --Chipset
            • 4.?re: 2011年9月26日
            • 問(wèn)這么多問(wèn)題,要求不低啊,呵呵,要回答好需要很扎實(shí)的基礎(chǔ)
            • --LoveBeyond
            • 5.?re: 2011年9月26日
            • 這些問(wèn)題我十有八九答不上來(lái)...慚愧啊
            • --pezy

            閱讀排行榜

            評(píng)論排行榜

            STL容器的學(xué)習(xí)總結(jié):
            第一:迭代器iterator
            首先,迭代器的定義,能夠用來(lái)遍歷STL容器中的部分或者全部元素,每個(gè)迭代器對(duì)象都代表著容易中的確定的地址,迭代器類似于指針類型,修改了常規(guī)指針的接口,是一種概念上的抽象,提供了*,++,==,!=,=操作,這些操作和C/C++操作數(shù)組元素時(shí)的指針接口一致。不同之處是該迭代器是一種smart pointer,具有遍歷復(fù)雜數(shù)據(jù)結(jié)構(gòu)的能力,所有操作行為都使用相同接口,雖然它們的型別不同。迭代器使開(kāi)發(fā)人員能夠在類或結(jié)構(gòu)中支持foreach迭代
            一般分為五種迭代器:輸入迭代器istream_iterator<>和istreambuf_iterator<>,輸出迭代器ostream_iterator<>和ostreambuf_iterator<>,前向迭代器,雙向迭代器,隨機(jī)訪問(wèn)迭代器
             back_insert_iterator<Container> 使用Container的push_back成員函數(shù)
             front_insert_iterator<Container> 使用Container的push_front成員函數(shù)
             insert_iterator<Container> 使用Container的insert成員函數(shù)
             reverse_iterator<Container> 從后向前使用Container的insert成員函數(shù)
             const——iterator<>
            二 分配算符(Allocators)

            看看stl中默認(rèn)的allocator:

             namespace std {
                  template <class T>
                  class allocator {
                    public:
                      //type definitions
                      typedef size_t    size_type;   //represent the size of the largest object in the allocation model
                      typedef ptrdiff_t difference_type; //The type for signed integral values that can represent the distance between any two pointers in the          

                                              //allocation model
                      typedef T*        pointer;
                      typedef const T*  const_pointer;
                      typedef T&        reference;
                      typedef const T&  const_reference;
                      typedef T         value_type;  //The type of the elements


                      //rebind allocator to type U
                      template <class U>
                      struct rebind {
                          typedef allocator<U> other;
                      };


                      //return address of values
                      pointer       address(reference value) const;
                      const_pointer address(const_reference value) const;


                      //constructors and destructor
                      allocator() throw();
                      allocator(const allocator&) throw();
                      template <class U>
                        allocator(const allocator<U>&) throw();
                      ~allocator() throw();


                      //return maximum number of elements that can be allocated
                      size_type max_size() const throw();


                      // allocate but don't initialize num elements of type T
                      pointer allocate(size_type num,
                                       allocator<void>::const_pointer hint = 0);


                      // initialize elements of allocated storage p with value value
                      void construct(pointer p, const T& value);


                      // delete elements of initialized storage p
                      void destroy(pointer p);


                      // deallocate storage p of deleted elements
                      void deallocate(pointer p, size_type num);
                  };
               }

            看了上面的allocator,我們已經(jīng)基本知道他的用處,他一般用在容器中,作為容器的一個(gè)成員,但一般是用模版參數(shù)傳入,這樣才可以讓我們換成我們自定義的allocator。

            vector就是動(dòng)態(tài)數(shù)組,在堆中分配內(nèi)存,元素連續(xù)存放,有保留內(nèi)存,如果減少大小后內(nèi)存也不會(huì)釋放。新值大于當(dāng)前大小時(shí)才會(huì)再分配內(nèi)存。[]可以使用,隨機(jī)插入,刪除要慢,快速的在末尾插入元素。最重要一點(diǎn)就是它的迭代器會(huì)失效。
            比如:typedef vector IntArray;
            IntArray array;
            array.push_back( 1 );
            array.push_back( 2 );
            array.push_back( 2 );
            array.push_back( 3 );
            // 刪除array數(shù)組中所有的2
            for( IntArray::iterator itor=array.begin(); itor!=array.end(); ++itor )
            {
                if( 2 == *itor ) array.erase( itor );
            }
            這樣是不行的,需要按照下面的實(shí)現(xiàn):
              for( IntArray::iterator itor=array.begin(); itor!=array.end(); ++itor )
                {
                  if( 2 == *itor )
                    {
                      array.erase( itor );
                      itor--;
                    }
                }
            deque,與vector類似,支持隨機(jī)訪問(wèn)和快速插入刪除。與vector不同的是,deque還支持從開(kāi)始端插入、刪除數(shù)據(jù)0,[]可以使用,速度沒(méi)有vector快。快速的訪問(wèn)隨機(jī)的元素。快速的在開(kāi)始和末尾插入元素,重新分配空間后,原有的元
            素不需要備份。對(duì)deque排序時(shí),可以先將deque的元素復(fù)制到vector,排序后在復(fù)制到deque

            list。只能順序訪問(wèn)不支持隨機(jī)訪問(wèn),不存在空間不夠
            關(guān)聯(lián)容器:更注重快速和高效的檢索數(shù)據(jù)的能力
            set:快速查找,不允許重復(fù)值。
            multiset快速查找,允許重復(fù)值。
            map:一對(duì)一映射,基于關(guān)鍵字快速查找,不允許重復(fù)值,key不能重復(fù)
            multimap一對(duì)多映射,基于關(guān)鍵字快速查找,允許重復(fù)值
            容器適配器:對(duì)已有的容器進(jìn)行某些特性的再封裝,

            stack:
            queue:
            (1)獲取向量中的元素值可用三種方式,直接用向量數(shù)組,獲得元素引用,獲得元素的指針。
            list:插入操作和刪除操作都不會(huì)造成原有的list迭代器失效,每次插入或刪除一個(gè)元素就配置或釋放一個(gè)元素空間,對(duì)于任何位置的元素插入或刪除,list永遠(yuǎn)是常數(shù)時(shí)間。


            posted on 2011-09-27 17:52 mengkai 閱讀(285) 評(píng)論(0)  編輯 收藏 引用

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


            亚洲日本va午夜中文字幕久久| 国产一区二区久久久| 欧美大香线蕉线伊人久久| 久久亚洲日韩看片无码| A级毛片无码久久精品免费| 无码人妻少妇久久中文字幕蜜桃 | 无码超乳爆乳中文字幕久久| 久久久久久久久久久久久久| 久久丫精品国产亚洲av| 色综合合久久天天综合绕视看| 精品久久久久久久久久久久久久久| 日韩美女18网站久久精品| 亚洲愉拍99热成人精品热久久| 国产精品一久久香蕉国产线看观看| 国产精品伦理久久久久久| 蜜桃麻豆WWW久久囤产精品| 久久精品一区二区国产| 久久午夜无码鲁丝片秋霞| 午夜天堂精品久久久久| 久久av高潮av无码av喷吹| 国产成人精品综合久久久久 | 精品999久久久久久中文字幕| 精品视频久久久久| 久久亚洲AV成人出白浆无码国产| 精品久久久久久久久久中文字幕 | 久久精品国产72国产精福利| 久久亚洲精精品中文字幕| 色婷婷久久久SWAG精品| 久久久精品一区二区三区| 99精品久久精品一区二区| 日产久久强奸免费的看| 日本一区精品久久久久影院| 精品久久久久久无码专区| 久久亚洲精品无码aⅴ大香| 亚洲一区精品伊人久久伊人| 久久综合久久久| 99久久精品费精品国产| 久久久国产精品福利免费 | 亚洲精品蜜桃久久久久久| 欧美一级久久久久久久大片| 久久国产成人午夜aⅴ影院|