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

            T9的空間

            You will never walk alone!

              C++博客 :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
              69 隨筆 :: 0 文章 :: 28 評(píng)論 :: 0 Trackbacks
            先看函數(shù):
            C++ Lists

            Lists are sequences of elements stored in a linked list. Compared to vectors, they allow fast insertions and deletions, but slower random access.

            Display all entries for C++ Lists on one page, or view entries individually:

            List constructors create lists and initialize them with some data
            List operators assign and compare lists
            assign assign elements to a list
            back returns a reference to last element of a list
            begin returns an iterator to the beginning of the list
            clear removes all elements from the list
            empty true if the list has no elements
            end returns an iterator just past the last element of a list
            erase removes elements from a list
            front returns a reference to the first element of a list
            insert inserts elements into the list
            max_size returns the maximum number of elements that the list can hold
            merge merge two lists
            pop_back removes the last element of a list
            pop_front removes the first element of the list
            push_back add an element to the end of the list
            push_front add an element to the front of the list
            rbegin returns a reverse_iterator to the end of the list
            remove removes elements from a list
            remove_if removes elements conditionally
            rend returns a reverse_iterator to the beginning of the list
            resize change the size of the list
            reverse reverse the list
            size returns the number of items in the list
            sort sorts a list into ascending order
            splice merge two lists in constant time
            swap swap the contents of this list with another
            unique removes consecutive duplicate elements

            要注意的是list不提隨機(jī)的迭代器,迭代器是個(gè)雙向的,非連續(xù)存儲(chǔ),而且是個(gè)環(huán)狀鏈表在尾端是個(gè)未初始化節(jié)點(diǎn)
            空判斷:begin==end;
            clear  remove  unique(把相同元素移出,留一個(gè)先sort)  insert(插入兩種方式)
            只能使用成員函數(shù) sort,不能使用 算法 sort(他只接受random iterator)

             1/*
             2  Name: C++ STL LIST    
             3  Copyright: 
             4  Author: Torres
             5  Date: 17-08-08 23:28
             6  Description: LIST 學(xué)習(xí)筆記 
             7*/

             8#include<iostream>
             9#include<list>
            10#include<vector>
            11#include<algorithm>
            12using namespace std;
            13typedef struct node{
            14    double x,y;
            15    node (double a=0,double b=0){
            16        x=a;
            17        y=b;
            18    }

            19}
            node;
            20void print(int a){printf("%d ",a);return;}
            21
            22ostream operator <<(ostream out,node a)
            23{
            24    return out<<a.x<<" "<<a.y<<endl;
            25}

            26int main()
            27{
            28    int i,j;
            29
            30    list<node>nlist;
            31    list<int>intlist,intlist1;
            32    
            33    vector<int>intv1,intv2;
            34    intv1.assign(5,7);
            35    intv2.assign(intv1.begin()+1,intv1.end()-1);
            36    for_each(intv2.begin()+1,intv2.end(),print);
            37    cout<<endl;
            38
            39    //assign的用法,有兩種,發(fā)現(xiàn)list的iterator不能夠相加而vector可以
            40    intlist.assign(5,7);
            41    intlist1.assign(intlist.begin(),intlist.end());
            42    for_each(intlist.begin(),intlist.end(),print);
            43    printf("\n");
            44    for_each(intlist1.begin(),intlist1.end(),print);
            45    printf("\n");
            46    
            47    //size的用法,表示實(shí)際數(shù)據(jù)的大小
            48    cout<<intlist.size()<<endl;
            49    //list沒有容量capacity函數(shù)
            50
            51    //因?yàn)閘ist是一個(gè)雙端鏈表,不支持隨機(jī)存取,他的存取必須用iterator來進(jìn)行
            52    //而vector,deque,等容器是支持的。
            53    list<int>::iterator it1;
            54    for(it1=intlist1.begin();it1!=intlist1.end();it1++)
            55        cout<<*it1<<" ";
            56    cout<<endl;
            57
            58    const node cnode(1.0,2.0);
            59    cout<<cnode<<endl;
            60
            61    nlist.assign(5,cnode);
            62    list<node>::iterator it2;
            63    for(it2=nlist.begin();it2!=nlist.end();it2++)
            64        cout<<*it2;
            65    return 0;
            66}

            67

            posted on 2008-08-17 23:30 Torres 閱讀(668) 評(píng)論(0)  編輯 收藏 引用

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


            亚洲精品无码久久久| 久久综合久久性久99毛片| 国产精品丝袜久久久久久不卡| 中文国产成人精品久久不卡 | 久久国产精品成人免费| 久久久久久久久久久精品尤物| 国产精品久久久久久久久久影院 | 久久精品成人一区二区三区| 狠狠色综合网站久久久久久久| 国产福利电影一区二区三区久久老子无码午夜伦不 | 久久99精品久久久久久齐齐| 国产亚洲欧美成人久久片| 浪潮AV色综合久久天堂| 国产精品免费福利久久| 国产一区二区精品久久| 国产精品天天影视久久综合网| 久久AAAA片一区二区| 久久久免费观成人影院| 亚洲国产精品综合久久网络| 亚洲欧洲精品成人久久曰影片| 热久久国产欧美一区二区精品| 奇米影视7777久久精品| 国产情侣久久久久aⅴ免费| 国产91色综合久久免费| 久久国产福利免费| 色妞色综合久久夜夜| 人妻丰满AV无码久久不卡| 狠狠色丁香婷婷综合久久来| 国产精品va久久久久久久| 久久久久一级精品亚洲国产成人综合AV区| 国产精品免费看久久久香蕉| 久久久久亚洲AV综合波多野结衣| 欧美日韩精品久久久久| 日本久久久久亚洲中字幕| 国产成人精品久久亚洲高清不卡| 久久人人爽人人爽人人片AV麻豆 | 久久久噜噜噜久久中文字幕色伊伊 | 精品久久一区二区三区| 亚洲精品99久久久久中文字幕| 色综合久久无码五十路人妻| 久久播电影网|