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

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

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

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: 

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.

c.insert(p,n,t)

list-----Inserts n elements with value t before the element referred to by iterator p. Returns void.

c.insert(p,b,e)

list-----Inserts elements in the range denoted by iterators b and e before the element referred to by iterator p. Returns void.

c1.swap(c2) 

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() 

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.


 

 

 

 





























 

转载于:https://my.oschina.net/wuying/blog/53501

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值