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

              C++博客 :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
              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 常興龍 閱讀(287) 評論(0)  編輯 收藏 引用
            > hi的博客
            国产成人99久久亚洲综合精品| 久久只有这里有精品4| 国产成人精品久久免费动漫| 久久这里只有精品久久| 亚洲午夜福利精品久久| 99久久精品毛片免费播放| 久久久久一本毛久久久| 色狠狠久久AV五月综合| 久久精品亚洲乱码伦伦中文| 国产成人久久AV免费| 亚洲午夜精品久久久久久app| 久久91精品久久91综合| 精品久久亚洲中文无码| 青草久久久国产线免观| 一级做a爱片久久毛片| 久久香蕉国产线看观看精品yw | 三级片免费观看久久| 国内精品久久久久影院优| 中文国产成人精品久久不卡 | 合区精品久久久中文字幕一区| 久久久精品国产sm调教网站| 免费无码国产欧美久久18| 久久艹国产| 久久99精品九九九久久婷婷| 欧美综合天天夜夜久久| 久久精品一区二区国产| 国产精品一久久香蕉国产线看| 亚洲午夜久久久久久久久电影网| 亚洲精品乱码久久久久久蜜桃| 久久国产热这里只有精品| 久久电影网| 欧美性大战久久久久久| 亚洲v国产v天堂a无码久久| 久久精品国产精品亚洲下载| 久久久久亚洲av毛片大| 亚洲国产香蕉人人爽成AV片久久| 午夜视频久久久久一区| 久久精品国产乱子伦| 精品永久久福利一区二区 | 亚洲国产精品久久久天堂| 久久久久亚洲av无码专区|