因为本节课老师也是再讲STL的基本用法,再加之平日工作也是经常使用STL,基本用法很熟悉了,所以水一周
STL六大部件
容器(Containers) 容器都是铅笔后来
分配器(Allocators)
算法(Algorithms)
迭代器(Iterators)
适配器(Adapters)
仿函数式(Functors)
最简单的例子
#include <vector>
#include <algorithm>
#include <functional>
#include <iostream>
using namespace std;
int main()
{
int ia[6] = { 23,43,54,12,4,67};
vector<int, allocator<int> > vi(ia, ia+6);
cout << count_if(vi.begin(), vi.end(),
bind2nd(less<int>(), 40)) <<endl;
return 0;
}
每次扩充多少
Array:不能扩充,指定多少就是多少
vector: 两倍增长
list:一个节点一个节点的分配,链式的查找慢
forward_list:一个节点一个节点的分配
deque:每次扩充是一个buff,