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

            常用鏈接

            留言簿

            隨筆分類

            隨筆檔案

            文章分類

            文章檔案

            搜索

            •  

            最新評論

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

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

            閱讀排行榜

            評論排行榜

            STL容器的學(xué)習(xí)總結(jié):
            第一:迭代器iterator
            首先,迭代器的定義,能夠用來遍歷STL容器中的部分或者全部元素,每個迭代器對象都代表著容易中的確定的地址,迭代器類似于指針類型,修改了常規(guī)指針的接口,是一種概念上的抽象,提供了*,++,==,!=,=操作,這些操作和C/C++操作數(shù)組元素時的指針接口一致。不同之處是該迭代器是一種smart pointer,具有遍歷復(fù)雜數(shù)據(jù)結(jié)構(gòu)的能力,所有操作行為都使用相同接口,雖然它們的型別不同。迭代器使開發(fā)人員能夠在類或結(jié)構(gòu)中支持foreach迭代
            一般分為五種迭代器:輸入迭代器istream_iterator<>和istreambuf_iterator<>,輸出迭代器ostream_iterator<>和ostreambuf_iterator<>,前向迭代器,雙向迭代器,隨機訪問迭代器
             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)基本知道他的用處,他一般用在容器中,作為容器的一個成員,但一般是用模版參數(shù)傳入,這樣才可以讓我們換成我們自定義的allocator。

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

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

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


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

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


            亚洲精品乱码久久久久久蜜桃图片| 久久精品无码一区二区app| 一级做a爰片久久毛片看看| 久久久久久国产精品无码下载| 国内精品久久久久影院薰衣草| 99久久这里只有精品| 久久人人爽人爽人人爽av | 精品久久综合1区2区3区激情| 日韩亚洲国产综合久久久| 久久久av波多野一区二区| 久久精品亚洲乱码伦伦中文| 亚洲精品无码久久久久久| 国产精品免费久久久久影院 | 精品久久久久中文字| 国产偷久久久精品专区| 国产午夜精品久久久久九九| 午夜精品久久久久久中宇| 性高湖久久久久久久久AAAAA| 久久亚洲AV成人无码电影| 久久这里都是精品| 99久久精品免费看国产一区二区三区| 免费久久人人爽人人爽av| 国产成人久久精品麻豆一区| 国产成人久久AV免费| 奇米影视7777久久精品| 国内精品久久国产| 久久只这里是精品66| 亚洲天堂久久久| 久久99热这里只有精品66| 无夜精品久久久久久| 色婷婷噜噜久久国产精品12p | 国产免费久久久久久无码| 久久99国产精品久久久| 久久久久国产精品熟女影院| 欧美一区二区三区久久综合| 亚洲AV无码久久精品成人| 一本一道久久综合狠狠老| 亚洲精品无码久久千人斩| 亚洲欧美日韩久久精品第一区| 精品久久久久久国产| 精品无码久久久久国产|