effective stl 读书笔记
来源:互联网 发布:python ssh执行.sh 编辑:程序博客网 时间:2024/05/01 19:02
1、函数声明中的函数参数:
int f(double d); 等价于 int f(double (d)); 等价于 int f(double);
int g(double (*pf)()); 等价于 int g(double pf()); 等价于 int g(double ());
2、choose carefully among erasing options
Container<int> c;
If you have a contiguous-memory container (vector, deque, or string — see Item 1),
the best approach is the erase-remove idiom (see Item 32):
c.erase( remove(c.begin(), c.end(), 1963), // the erase-remove idiom is
c.end()); //the best way to get rid of
// elements with a specific
// value when c is a vector,
//string, or deque(deque底层实现在sgi版本中貌似是红黑树啊)
c. remove(1963); //the remove member function is the
// best way to get rid of elements with
// a specific value when c is a list
c.erase(1963); // the erase member function is the
// best way to get rid of elements with
// a specific value when c is a
// standard associative container
3、If you're updating an existing map element, operator[] is preferable, but if you're adding a new element, insert has the edge.
4、Some of you, I know, are into brute-force memorization, so here's a list of the
algorithms that require the data on which they operate to be sorted:
binary_search lower_bound
upper_bound equal_range
set_union Set_intersection
set_difference set_symmetric_difference
Merge inplace_merge
includes
In addition, the following algorithms are typically used with sorted ranges, though they
don't require them:
unique unique_copy
5、文件操作
ifstream inputFile("exa.txt");
inputFile.unsetf(ios::skipws); //disable the skipping of whitespace in inputFile.
string fileData((istreambuf_iterator<char>(inputFile)), istreambuf_iterator<char>());
cout << fileData << endl;
ofstream outputFile("opt.txt");
outputFile.unsetf(ios::skipws);
ostreambuf_iterator<char> out_it(outputFile);
copy(fileData.begin(), fileData.end(), out_it);
- Effective STL 读书笔记 1
- Effective STL 读书笔记 2
- Effective STL 读书笔记 3
- Effective STL 读书笔记 4
- Effective STL 读书笔记 5
- Effective STL 读书笔记 6
- Effective STL 读书笔记 7
- Effective STL 读书笔记 8
- Effective STL 读书笔记 9
- effective stl 读书笔记
- effective STL 读书笔记 二
- 读书笔记 Effective STL
- 《Effective STL》读书笔记
- 《Effective STL》读书笔记
- effective STL读书笔记
- Effective STL 读书笔记
- 《Effective STL》读书笔记
- Effective STL读书笔记-第一章
- 第一次启动分页管理
- C#编程QQ群收藏
- 初始化中断描述符表
- 乐清村长
- 加载全局/中断描述符表
- effective stl 读书笔记
- JQuery Plugins
- 用编译选项帮你挑错
- XML应用样例:Atom到RSS转换
- 第三次启动保护模式
- c#使用指针快速操作图片
- 2010过去,2011开始了
- 掌握Dojo工具包,第1部分:Dojo入门简介(1)
- VS2010能否取代VS6?微软能否再创辉煌!