• <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++細節(jié)深度探索及軟件工程

              C++博客 :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
              37 隨筆 :: 0 文章 :: 74 評論 :: 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 常興龍 閱讀(289) 評論(0)  編輯 收藏 引用

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


            > hi的博客
            性色欲网站人妻丰满中文久久不卡| 99精品久久精品一区二区| 青青青青久久精品国产h久久精品五福影院1421 | 日韩中文久久| 久久久久亚洲AV成人片| 国产免费久久久久久无码| 亚洲国产日韩欧美综合久久| 亚洲午夜久久久影院| 99久久精品免费观看国产| 久久精品一本到99热免费| 久久福利青草精品资源站| 亚洲午夜久久影院| 中文字幕无码久久精品青草| 精品久久久久久中文字幕人妻最新 | 亚洲人成精品久久久久| 伊人久久大香线蕉精品| 色综合久久无码五十路人妻| 久久精品免费网站网| 狠狠狠色丁香婷婷综合久久五月| 久久精品免费全国观看国产| 中文字幕一区二区三区久久网站| 奇米综合四色77777久久| 偷偷做久久久久网站| 久久嫩草影院免费看夜色| 久久综合狠狠综合久久激情 | 久久精品久久久久观看99水蜜桃| 久久这里只有精品久久| 久久综合国产乱子伦精品免费| 亚洲国产成人久久精品99| 老司机午夜网站国内精品久久久久久久久| 久久精品国产亚洲AV麻豆网站| 97精品依人久久久大香线蕉97 | 日韩十八禁一区二区久久| A级毛片无码久久精品免费| 夜夜亚洲天天久久| 91久久精品视频| 久久久精品久久久久久| 日本亚洲色大成网站WWW久久| 欧美无乱码久久久免费午夜一区二区三区中文字幕 | 久久久一本精品99久久精品66| 久久91精品国产91|