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

            C++研究

            C++細(xì)節(jié)深度探索及軟件工程

              C++博客 :: 首頁(yè) :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
              37 隨筆 :: 0 文章 :: 74 評(píng)論 :: 0 Trackbacks
            By default, you should use a vector. It has the simplest internal data structure and
            provides random access. Thus, data access is convenient and flexible, and data
            processing is often fast enough.

            • If you insert and/or remove elements often at the beginning and the end of a sequence,
            you should use a deque. You should also use a deque if it is important that the amount of
            internal memory used by the container shrinks when elements are removed. Also,
            because a vector usually uses one block of memory for its elements, a deque might be
            able to contain more elements because it uses several blocks.

            • If you insert, remove, and move elements often in the middle of a container, consider
            using a list. Lists provide special member functions to move elements from one container
            to another in constant time. Note, however, that because a list provides no random access, you might suffer significant performance penalties on access to elements inside
            the list if you only have the beginning of the list.
            Like all node-based containers, a list doesn't invalidate iterators that refer to elements, as
            long as those elements are part of the container. Vectors invalidate all of their iterators,
            pointers, and references whenever they exceed their capacity, and part of their iterators,
            pointers, and references on insertions and deletions. Deques invalidate iterators,
            pointers, and references when they change their size, respectively.

            • If you need a container that handles exceptions in a way that each operation either
            succeeds or has no effect, you should use either a list (without calling assignment
            operations and sort() and, if comparing the elements may throw, without calling merge
            (), remove(), remove_if(), and unique(); see page 172) or an associative
            container (without calling the multiple-element insert operations and, if copying/assigning
            the comparison criterion may throw, without calling swap()). See Section 5.11.2, for a
            general discussion of exception handling in the STL and Section 6.10.10, for a table of
            all container operations with special guarantees in face of exceptions.

            • If you often need to search for elements according to a certain criterion, use a set or a
            multiset that sorts elements according to this sorting criterion. Keep in mind that the
            logarithmic complexity involved in sorting 1,000 elements is in principle ten times better
            than that with linear complexity. In this case, the typical advantages of binary trees apply.
            A hash table commonly provides five to ten times faster lookup than a binary tree. So if a
            hash container is available, you might consider using it even though hash tables are not
            standardized. However, hash containers have no ordering, so if you need to rely on
            element order they're no good. Because they are not part of the C++ standard library, you
            should have the source code to stay portable.

            Quoted from STL_tutorial_reference
            posted on 2007-04-21 14:39 常興龍 閱讀(286) 評(píng)論(0)  編輯 收藏 引用

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


            > hi的博客
            色综合久久久久综合99| 精品国际久久久久999波多野| 久久av无码专区亚洲av桃花岛| 久久91这里精品国产2020| 久久免费高清视频| 国产99久久九九精品无码| 国产成人精品久久免费动漫| 人人狠狠综合久久88成人| 久久婷婷五月综合色高清| www性久久久com| 久久久中文字幕| 久久久久久A亚洲欧洲AV冫| 久久精品国产色蜜蜜麻豆| 色综合合久久天天给综看| 囯产极品美女高潮无套久久久| 99蜜桃臀久久久欧美精品网站| 亚洲国产精品高清久久久| MM131亚洲国产美女久久| 91视频国产91久久久| 99久久国产综合精品成人影院| 久久久精品午夜免费不卡| 久久国产香蕉视频| 99久久99久久精品国产片果冻| 久久综合噜噜激激的五月天| 日韩精品国产自在久久现线拍| 久久av免费天堂小草播放| 欧美精品丝袜久久久中文字幕 | 一本久久综合亚洲鲁鲁五月天亚洲欧美一区二区 | 影音先锋女人AV鲁色资源网久久| 亚洲色欲久久久综合网| 亚洲国产精品久久久久| 女人高潮久久久叫人喷水| 97久久超碰国产精品2021| 久久精品国产欧美日韩| 久久久久久国产精品免费无码 | 久久久久亚洲AV无码去区首| 久久精品久久久久观看99水蜜桃| 久久国产精品久久国产精品| 日本五月天婷久久网站| 精品久久久久久国产91| 亚洲精品无码成人片久久|