• <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++博客 :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
              69 隨筆 :: 0 文章 :: 28 評論 :: 0 Trackbacks
            C++ Double-ended Queues

            Double-ended queues are like vectors, except that they allow fast insertions and deletions at the beginning (as well as the end) of the container.

            Display all entries for C++ Double-ended Queues on one page, or view entries individually:

            Container constructors create dequeues and initialize them with some data
            Container operators compare, assign, and access elements of a dequeue
            assign assign elements to a dequeue
            at returns an element at a specific location
            back returns a reference to last element of a dequeue
            begin returns an iterator to the beginning of the dequeue
            clear removes all elements from the dequeue
            empty true if the dequeue has no elements
            end returns an iterator just past the last element of a dequeue
            erase removes elements from a dequeue
            front returns a reference to the first element of a dequeue
            insert inserts elements into the dequeue
            max_size returns the maximum number of elements that the dequeue can hold
            pop_back removes the last element of a dequeue
            pop_front removes the first element of the dequeue
            push_back add an element to the end of the dequeue
            push_front add an element to the front of the dequeue
            rbegin returns a reverse_iterator to the end of the dequeue
            rend returns a reverse_iterator to the beginning of the dequeue
            resize change the size of the dequeue
            size returns the number of items in the dequeue
            swap swap the contents of this dequeue with another

            在我看來,deque就是一個雙端的array,和vector是一摸一樣的,雖然內部機制不一樣
             1/*
             2  Name: C++ DEQUE   
             3  Copyright: 
             4  Author: Torres
             5  Date: 18-08-08 10:55
             6  Description: STL DEQUE 學習筆記 
             7*/

             8#include<deque>
             9#include<iostream>
            10#include<algorithm>
            11using namespace std;
            12#define showpass cout<<"pass"<<endl
            13typedef struct point{
            14    double x,y;
            15    point(double a=0,double b=0){
            16        x=a;
            17        y=b;
            18    }

            19}
            point;
            20ostream operator<<(ostream out,point a)
            21{
            22    return out<<a.x<<" "<<a.y<<endl;
            23}

            24
            25void print(point a)
            26{
            27    cout<<a;
            28}

            29int main()
            30{
            31    //deque與vector很相似只不過是兩端都可以存取的vector
            32    deque<point>cp,cp1(10);
            33    int i;
            34    for(i=0;i<5;i++){
            35        point temp(i,i+1);
            36        cp.push_back (temp);
            37    }

            38    
            39    for(i=0;i<5;i++){
            40        cp1[i].x=i;
            41        cp1[i].y=i+1;
            42    }

            43    //取地址符號[]必須在容器已經開辟空間后才能用,push函數開辟了新空間
            44    for_each(cp.begin(),cp.end(),print);
            45    cout<<endl;
            46    for_each(cp1.begin(),cp1.end()-5,print);
            47    cout<<endl;
            48    
            49    //erase刪除函數
            50    cp.erase(cp.begin()+1);
            51    for_each(cp.begin(),cp.end(),print);
            52    cout<<endl;
            53    cp1.erase(cp1.begin(),cp1.begin()+3);
            54    for_each(cp1.begin(),cp1.end()-5,print);
            55    cout<<endl;
            56
            57    cout<<cp.front()<<cp.back()<<endl; 
            58
            59
            60    return 0;
            61}

            posted on 2008-08-18 11:02 Torres 閱讀(660) 評論(0)  編輯 收藏 引用
            国产精品99久久久久久人| 欧美久久精品一级c片片| 亚洲国产成人久久综合一区77| 久久久久国产一级毛片高清板| 国产午夜精品久久久久九九电影| 开心久久婷婷综合中文字幕| 伊人久久大香线蕉av一区| 久久午夜电影网| 久久精品aⅴ无码中文字字幕不卡 久久精品成人欧美大片 | 狠狠色丁香久久婷婷综合蜜芽五月| 东方aⅴ免费观看久久av| 99久久精品免费看国产一区二区三区| 日本精品一区二区久久久| 久久久久亚洲av无码专区导航 | 欧美久久天天综合香蕉伊| 久久精品国产精品亚洲人人 | 久久99精品久久久久久9蜜桃 | 蜜臀av性久久久久蜜臀aⅴ麻豆 | 国产精品一久久香蕉国产线看观看| 久久中文字幕无码专区| 国产视频久久| 无码伊人66久久大杳蕉网站谷歌| 精品久久久久久中文字幕| 亚洲伊人久久综合影院| 久久九九全国免费| 久久这里只有精品首页| 中文字幕一区二区三区久久网站| 久久精品国产久精国产果冻传媒 | 国产亚洲精午夜久久久久久 | 久久91精品久久91综合| 久久伊人精品青青草原日本| 99久久精品毛片免费播放| 亚洲一区中文字幕久久| 精品熟女少妇a∨免费久久| 狠狠色婷婷久久一区二区| 日批日出水久久亚洲精品tv| 成人精品一区二区久久久| 久久综合狠狠综合久久激情 | 国产精品免费看久久久| 日本欧美久久久久免费播放网| 狠狠色丁香久久婷婷综合_中|