StupidBeauty
Read times:581Posted at:Sat Apr 20 19:56:28 2013
- no title specified

转载 标准C++中string类及STL容器类简介(转)

可使用reverse函数来将一个vector反转。

http://www.cnblogs.com/zhoutian6214/archive/2009/06/20/1507469.html

亮点:

. 向量类模板 std::vector 成员函数:

#include<vector>

std:: vector <type> name;

std:: vector <type> name(size);

std:: vector <type> name(size,value);

std:: vector <type> name(my vector );

std:: vector <type> name(first,last);

assign(first,last) 用迭代器 first,last 所指定的元素取代向量元素

assign(num,val) val num 份副本取代向量元素

at(n) 等价于 [] 运算符,返回向量中位置 n 的元素

front() 返回向量中第一个元素的引用

back() 返回向量中最后一个元素的引用

begin() 返回向量中第一个元素的迭代器

end() 返回向量中最后一个元素的迭代器

max_size() 返回向量的最大容量(向量所能容纳的最多元素个数)

capacity() 返回向量当前所能容纳的最多元素个数

clear() 删除向量中所有元素

empty() 如果向量为空,返回真

erase(start,end) 删除迭代器 start end 所指定范围内的元素

erase(i) 删除迭代器 i 所指向的元素

insert(i,x) x 插入到迭代器 i 所指定的位置

insert(i,n,x) x n 份副本插入到迭代器 i 所指定的位置

insert(i,start,end) 把迭代器 start end 所指定的范围内的值插入到迭代器 i 所指定的位置

push_back(x) x 插入到向量的尾部

pop_back() 删除向量中最后一个元素

rbegin() 返回一个反向迭代器,该迭代器指向的元素越过了向量中的最后一个元素

rend() 返回一个反向迭代器,该迭代器指向向量中第一个元素

reverse() 反转元素顺序

Eva

Your opinions
Your name:Email:Website url:Opinion content:
- no title specified

HxLauncher: Launch Android applications by voice commands

 
Recent comments
2017年4月~2019年4月垃圾短信排行榜Posted at:Thu Sep 26 04:51:48 2024
Qt5.7文档翻译:QWebEngineCookieStore类,QWebEngineCookieStore ClassPosted at:Fri Aug 11 06:50:35 2023盲盒kill -9 18289 Grebe.20230517.211749.552.mp4