版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
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等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 塑料制品的材料選擇與性能測試考核試卷
- 二零二五年度海洋資源開發(fā)與利用合同6篇
- 2025年度鮮奶產品質量認證與標準制定合同3篇
- SnSe薄膜制備及其鈍化特性研究
- 明清禮制下的永順土司區(qū)建筑研究
- 可見光通信PAM4調制解調系統(tǒng)設計
- 福建省莆田一中等三校2024屆高三數(shù)學試題3月11日第2周測試題
- 2025年度雞蛋買賣合同履行保障措施3篇
- 2025-2030全球工業(yè)壓塊機行業(yè)調研及趨勢分析報告
- 2025-2030全球衛(wèi)生用品膠粘劑行業(yè)調研及趨勢分析報告
- GB/T 9978.5-2008建筑構件耐火試驗方法第5部分:承重水平分隔構件的特殊要求
- 上海紐約大學自主招生面試試題綜合素質答案技巧
- 辦公家具項目實施方案、供貨方案
- 2022年物流服務師職業(yè)技能競賽理論題庫(含答案)
- ?;钒踩僮饕?guī)程
- 連鎖遺傳和遺傳作圖
- DB63∕T 1885-2020 青海省城鎮(zhèn)老舊小區(qū)綜合改造技術規(guī)程
- 高邊坡施工危險源辨識及分析
- 中海地產設計管理程序
- 簡譜視唱15942
- 《城鎮(zhèn)燃氣設施運行、維護和搶修安全技術規(guī)程》(CJJ51-2006)
評論
0/150
提交評論