从「林」开始--C++ primer 读书笔记 -- Part II: Containers ...

             从「林」开始--C++ primer 读书笔记 -- Part II: Containers and Algorithms

######################################################
// 声明 : 1 笔记基本都是从《C++ Primer第四版中英文对照.chm》复制而来!
                 2 延伸的知识会以黄色字体高亮,欢迎拍砖
                 3 我的阅读重点将用红色字体高亮!
######################################################dom

Chapter 9. Sequential Containers

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.
相关文章
相关标签/搜索