從「林」開始--C++ primer 讀書筆記 -- Part II: Containers and Algorithms
######################################################
// 聲明 : 1 筆記基本都是從《C++ Primer第四版中英文對照.chm》複製而來!
2 延伸的知識會以黃色字體高亮,歡迎拍磚
3 我的閱讀重點將用紅色字體高亮!
######################################################dom
1:The library defines three kinds of sequential containers: vector(Supports fast random access), list(Supports fast insertion/deletion), and deque (short for "double-ended queue" and pronounced "deck").
2: // copy elements from vec into ilist
list<int> ilist(vec.begin(), vec.end());
ilist.begin() + ilist.size()/2; // error: no addition on list iterators
The list iterator does not support the arithmetic operationsaddition or subtractionnor does it support the relational (<=, <, >=, >) operators. It does support pre- and postfix increment and decrement and the equality (inequality) operators.
3: post
c.insert(p,t)字體 |
list-----Inserts element with value t before the element referred to by iterator p. Returns an iterator referring to the element that was added.spa |
c.insert(p,n,t)three |
list-----Inserts n elements with value t before the element referred to by iterator p. Returns void.ci |
c.insert(p,b,e)element |
list-----Inserts elements in the range denoted by iterators b and e before the element referred to by iterator p. Returns void.rem |
c1.swap(c2) it |
vector----Swaps contents: After the call c1 has elements that were in c2, and c2 has elements that were in c1. c1 and c2 must be the same type. Execution time usually much faster than copying elements from c2 to c1 |
c.pop_back() io |
list-----Removes the last element in c. Returns void. Undefined if c is empty. |
c.pop_front() | Removes the first element in c. Returns void. Undefined if c is empty. |