• <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)舉個例子說明你學習能力比較強,
              牛!

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

            閱讀排行榜

            評論排行榜

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

            看看stl中默認的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,我們已經基本知道他的用處,他一般用在容器中,作為容器的一個成員,但一般是用模版參數傳入,這樣才可以讓我們換成我們自定義的allocator。

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

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

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


            posted on 2011-09-27 17:52 mengkai 閱讀(281) 評論(0)  編輯 收藏 引用
            18岁日韩内射颜射午夜久久成人| 国产69精品久久久久99尤物| 99久久婷婷国产一区二区| 久久精品人人做人人爽电影蜜月| 中文国产成人精品久久亚洲精品AⅤ无码精品 | 精品久久久久久久国产潘金莲 | 久久精品中文字幕第23页| 91精品国产91久久久久福利| 久久久久亚洲AV无码网站| 亚洲精品成人网久久久久久| 武侠古典久久婷婷狼人伊人| 欧美久久亚洲精品| 国产成人综合久久精品红| 国产精品久久久久免费a∨| 精品久久久中文字幕人妻| 一本一本久久A久久综合精品| 亚洲国产另类久久久精品黑人| 精品久久人人爽天天玩人人妻| 亚洲国产精品高清久久久| 亚洲中文字幕无码久久2020| 欧美大香线蕉线伊人久久| 久久精品午夜一区二区福利| 青青青国产精品国产精品久久久久 | 日韩精品久久无码人妻中文字幕| 少妇久久久久久久久久| 精品乱码久久久久久久| 国产免费福利体检区久久| 久久人人爽人爽人人爽av| 精品熟女少妇AV免费久久| 少妇精品久久久一区二区三区 | 一本大道加勒比久久综合| 日批日出水久久亚洲精品tv| 亚洲中文久久精品无码| 国产美女久久久| 久久久久香蕉视频| 亚洲精品无码久久久影院相关影片| 久久大香香蕉国产| 久久无码AV中文出轨人妻| 亚洲va中文字幕无码久久| 亚洲成色999久久网站| 久久亚洲色一区二区三区|