#include
1. find()函数
2. accumulate()函数
3. find_first_of()函数的两个range的类型可以不同,但是两个range内部的类型必须相同。
4. fill()函数,使用时必须保证空间是足够的。
fill_n(back_inserter(vec), 10, 0);//appends 10 elements to vec
5. replace()函数改变容器内部,replace_copy()函数不改变容器内部,而是自己新拷贝一份。
6. sort()函数,unique()函数,unique_copy()函数,stable_sort()函数,count_if()函数
7. back_inserter, front_inserter, inserter
front_inserter requires push_front, so using front_inserter on a vector, or other container that does not have push_front, is an error.
用front_inserter与用inserter(container, container.begin())效果不一样
8. istream_iterator
通过输入创建vector:
istream_iterator<int> in_iter(cin); istream_iterator<int> eof; vector<int> vec(in_ter, eof);
9. 学会用string(it1, it2)来新创建一个string
10. reverse_iterator的base()函数
11. Algorithms require the iterators that denote a range to have exactly the same type.
12. input iterators ->istream_iterator
output iterators ->ostream_iterator
forward iterators ->replace()的参数
bidirectional iterators ->reverse()的参数
random-access iterators ->sort()的参数,vector,deque,string的iterators
13. When dealing with algorithms, it is best to think of the iterators on associative containers as if they were input iterators that support decrement, not as full bidirectional iterators.
14. list用其自身的成员函数,sort, unique, remove, reverse, merge, splice.
#include#include #include #include #include