• <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>
            隨筆 - 25  文章 - 29  trackbacks - 0
            <2007年6月>
            272829303112
            3456789
            10111213141516
            17181920212223
            24252627282930
            1234567

            常用鏈接

            留言簿(4)

            隨筆分類(22)

            隨筆檔案(25)

            文章分類(2)

            文章檔案(2)

            相冊(cè)

            最新隨筆

            搜索

            •  

            積分與排名

            • 積分 - 56642
            • 排名 - 405

            最新評(píng)論

            閱讀排行榜

            評(píng)論排行榜

            ???

            Containers in STL can be divided into three categories:
            1.sequence containers,
            2.associative containers,
            3.container adapters.

            1.Sequence Containers

            Sequence containers maintain the original ordering of inserted elements. This allows you to specify where to insert the element in the container.

            The deque (double-ended queue) container allows for fast insertions and deletions at the beginning and end of the container. You can also randomly access any element quickly.

            The list container allows for fast insertions and deletions anywhere in the container, but you cannot randomly access an element in the container.

            The vector container behaves like an array, but will automatically grow as required.

            For more information on the sequence containers, consult the following table:

            Sequence Container Native STL

            deque

            deque Class

            ilist

            Not Applicable

            list

            list Class

            vector

            vector Class

            2.Associative Containers

            The defining characteristic of associative containers is that elements are inserted in a pre-defined order, such as sorted ascending.

            The associative containers can be grouped into two subsets: maps and sets. A map, sometimes referred to as a dictionary, consists of a key/value pair. The key is used to order the sequence, and the value is somehow associated with that key. For example, a map might contain keys representing every unique word in a text and values representing the number of times that word appears in the text. A set is simply an ascending container of unique elements.

            Both map and set only allow one instance of a key or element to be inserted into the container. If multiple instances of elements are required, use multimap or multiset.

            Both maps and sets support bidirectional iterators. For more information on iterators, see Iterators.

            While not officially part of the STL standard, hash_map and hash_set are commonly used to improve searching times. These containers store their elements as a hash table, with each table entry containing a bidirectional linked list of elements. To ensure the fastest search times, make sure that the hashing algorithm for your elements returns evenly distributed hash values.

            For more information on the associative containers, consult the following table:

            Associative Container Native STL

            hash_map

            hash_map Class

            hash_multimap

            hash_multimap Class

            hash_multiset

            hash_multiset Class

            hash_set

            hash_set Class

            map

            map Class

            multimap

            multimap Class

            multiset

            multiset Class

            set

            set Class



            3.Container Adapters

            The container adapters are simply variations of the above containers. The container adapters do not support iterators.

            The priority_queue container organized such that the element with the highest value is always first in the queue.

            The queue container follows FIFO (first in, first out) semantics. The first element inserted (pushed) into the queue is the first to be removed (popped).

            The stack container follows LIFO (last in, first out) semantics. The last element to be inserted (pushed) on the stack is the first element to be removed (popped).

            Since container adapters do not support iterators, they cannot be used with the STL algorithms. For more information on algorithms, see Algorithms.

            For more information on the container adapters, consult the following table:

            Container Adapter Native STL

            priority_queue

            priority_queue Class

            queue

            queue Class

            stack

            stack Class




            Requirements for Container Elements

            Elements inserted into an STL container can be of any object type that supplies a public copy constructor, a public?
            ????????????????????????????????????? public 拷貝構(gòu)造 ,public 析構(gòu) ,public 賦值操作符?? elem& operator =( elem const &)
            destructor, and a public assignment operator. The destructor may not throw an exception. Furthermore, associative?
            ?????????????????????????????????????????????????????????????????????? 析構(gòu)不能拋出異常
            containers such as set and map must have a public comparison operator defined, which is operator< by default. Some?
            ???????????????????????????? 關(guān)聯(lián)容器? 除此外 還應(yīng)由有 比較操作符
            ??????????????????operations on containers might also require a public default constructor and a public equivalence operator.




            以下是? 各容器 迭代器類型輸出代碼

            ?1#include?<vector>
            ?2#include?<list>
            ?3#include?<deque>
            ?4#include?<set>
            ?5#include?<map>
            ?6using?namespace?std;
            ?7template?<typename?inputitrator?>
            ?8void?predict(inputitrator??a)
            ?9{???iterator_traits<inputitrator>::iterato_category??b;
            10???
            11???cout<<?endl<<?"??"<<typeid(b).name();
            12}

            13
            14
            15main()
            16
            17{
            18??vector<int>?a;
            19??deque<int>?b;
            20??list<int>?c;
            21??set<int>?d;
            22??map<int>?e;
            23??
            24???predict(a.begin());
            25???predict(b.begin());
            26???predict(c.begin());
            27????predict(d.begin());
            28?????predict(e.begin());
            29
            30}
            output iterator
               -> forward iterator
               -> bidirectional iterator
               -> random-access iterator

            input iterator
               -> forward iterator
               -> bidirectional iterator
               -> random-access iterator
            posted on 2006-09-18 10:43 黃大仙 閱讀(2079) 評(píng)論(0)  編輯 收藏 引用 所屬分類: c++
            久久精品这里只有精99品| 国产精品国色综合久久| 久久亚洲国产精品123区| 久久九九久精品国产免费直播| 日日狠狠久久偷偷色综合免费| 国产亚洲精久久久久久无码77777 国产亚洲精品久久久久秋霞 | 久久久久久久久久久免费精品| 亚洲国产精品无码久久青草| 老色鬼久久亚洲AV综合| 久久久精品日本一区二区三区 | 久久精品无码一区二区三区| 久久精品视频91| 久久99精品久久久久久hb无码| 久久久久久国产a免费观看不卡 | 久久午夜免费视频| 久久这里只精品国产99热 | 久久精品嫩草影院| 国产69精品久久久久9999APGF| 亚洲国产精品久久久久| 亚洲国产精品一区二区久久hs| 欧洲国产伦久久久久久久| 久久精品国产免费一区| 蜜臀久久99精品久久久久久小说| 日本欧美国产精品第一页久久| 青青青青久久精品国产h| 久久精品亚洲中文字幕无码麻豆| 久久精品综合网| 香蕉久久AⅤ一区二区三区| 久久99精品国产一区二区三区| 三上悠亚久久精品| 久久亚洲av无码精品浪潮| 99久久国产热无码精品免费久久久久| 久久久国产乱子伦精品作者| 亚洲人成伊人成综合网久久久| 国产精品久久久久久久久软件| 亚洲精品乱码久久久久久蜜桃 | 性欧美丰满熟妇XXXX性久久久 | 亚洲中文字幕无码一久久区| 一级女性全黄久久生活片免费 | 久久人人爽人爽人人爽av| 国产免费久久精品丫丫|