版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
1、 271 Vector Vector Deque Deque . , . , , . , . , : - ; - ; - . , , / . , , . , . #include using namespace std; int main(int argc, char* argv) vector v1; / int vector v2; / double vector v3; / bool vector v4; / string return EXIT_SUCCESS; vectorvector matrix; / Vector 3 Vector 3 #include using namesp
2、ace std; int main(int argc, char* argv) vector v1; / initially empty vector v2(5); / 5 elements, initialized to 0 vector v3(10, 1); / 10 elements, initialized to 1 vector v4(v3); / v4 is a copy of v3 return EXIT_SUCCESS; (constructor)(constructor) (public member function) (destructor)(destructor) (p
3、ublic member function) operator=operator= (public member function) : beginbegin (public member type) endend (public member function) rbeginrbegin (public member function) rendrend (public member function); : sizesize (public member function) max_sizemax_size (public member function) resizeresize (pu
4、blic member function) capacitycapacity (public member function) emptyempty , (public member function) reservereserve (public member function) Vector 5Vector 5 : : operatoroperator (public member function) atat (public member function) frontfront (public member function) backback (public member funct
5、ion) : assignassign (public member function) push_backpush_back (public member function) pop_backpop_back (public member function) insertinsert (public member function) eraseerase (public member function) swapswap (public member function) clearclear (public member function) : get_allocatorget_alloca
6、tor (public member function) Vector 6Vector 6 / vector v; / for (int i = 0; i 5; i+) v.push_back(i); cout Size: v.size() endl; / for (int j = 0; j 5; j+) v.pop_back(); cout Size: v.size() endl; cout endl v.empty() endl; / : vector v(12); v1 = 3; v.at(2) = 90; v.front() = v.back(); Vector 7 Vector 7
7、/ vector:iterator it; for (it = v.begin(); it != v.end(); it+) cout *it endl; / v.insert(v.begin(), 70); cout v0 endl; cout v.size() endl; / 6 vector:iterator it = v.end() - 6; v.erase(it, v.end(); cout v.size() endl; Vector 8 Vector 8 Deque double-ended queue. - . , . , , . . , . : - ; - ; - . , ,
8、. deque(); / deque deque( size_type size ); / deque size deque( size_type num, const TYPE /c num val - num val deque deque( input_iterator start, input_iterator end ); / start end deque (start) (end). assignassign Syntax: void assign( input_iterator start, input_iterator end); void assign( Size num,
9、 const TYPE . atat Syntax: reference at( size_type pos ); pos. backback Syntax: reference back(); . beginbegin Syntax: iterator begin(); . clearclear Syntax: void clear(); . emptyempty Syntax: bool empty(); true, . false. endend Syntax: iterator end(); . eraseerase Syntax: iterator erase( iterator p
10、os ); . frontfront Syntax: reference front(); . insertinsert Syntax: iterator insert( iterator pos, size_type num, const TYPE num val pos. max_sizemax_size Syntax: size_type max_size(); , . pop_backpop_back Syntax: void pop_back(); . pop_frontpop_front Syntax: void pop_front(); . push_backpush_back
11、Syntax: void push_back( const TYPE . push_frontpush_front Syntax: void push_front( const TYPE . rbeginrbegin Syntax: reverse_iterator rbegin(); . rendrend Syntax: reverse_iterator rend(); . resizeresize Syntax: void resize( size_type num, TYPE val ); num, , val. sizesize Syntax: size_type size(); .
12、swapswap Syntax: void swap( deque double. / 1 deque dq( 10, 1 ); / :iterator iter; / dq.push_back (8); / dq.push_front (9); / dq.pop_front (); / for( iter = dq.begin(); iter != dq.end(); iter+ ) cout *iter endl; / dq.clear(); Vector Deque , : 1) deque . 2) : (!) -vector . 2 ( Visual C+ 6.0). . , . ,
13、 n*K , K , , (1+sqrt(5)/2. n, , n . , , . - . -deque . . , vector . 1. deque deque insert() and erase() 0 (1) , . capacity(), back(), clear(), destroy(), value(), pop_back(). 2.dequedeque , vectorvector. , vectorvector dequedeque -capacity() and reserve(). 3. - deque vectora push_back() 4. reserve() . dequ
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 航空航天器工具管理
- 服裝企業(yè)出納聘用合同
- 食用菌種植化建設(shè)
- 天然氣工程大清包施工合同
- 2025技術(shù)咨詢合同樣本
- 旅游景點(diǎn)圍護(hù)樁施工合同
- 籃球場建設(shè)配套合同
- 2025版綠色物流貨物運(yùn)輸合同規(guī)范3篇
- 2024年皮革原材料供應(yīng)合同
- 2025版“煤炭銷售合同”英文修訂版3篇
- 某煤礦潰倉事故專項(xiàng)安全風(fēng)險(xiǎn)辨識(shí)評(píng)估報(bào)告示例
- “雙減”背景下初中數(shù)學(xué)作業(yè)設(shè)計(jì)新思路 論文
- 【幼兒園班本課程研究文獻(xiàn)綜述4100字(論文)】
- 上頜竇瘺修補(bǔ)術(shù)課件
- 支部書記辭職申請(qǐng)書
- 國家開放大學(xué)電大《美學(xué)原理》形考任務(wù)1-4試題和答案
- 現(xiàn)場生命急救知識(shí)與技能學(xué)習(xí)通期末考試答案2023年
- 《HSK標(biāo)準(zhǔn)教程3》第18課課件
- 清掃保潔及垃圾清運(yùn)承包合同
- 聯(lián)通公司集團(tuán)大客戶業(yè)務(wù)開通項(xiàng)目管理實(shí)施細(xì)則(試行)
- 真空管太陽能熱水工程解決方案
評(píng)論
0/150
提交評(píng)論