六大部件

# include <iostream>
# include <vector>
# include <algorithm>
# include <functional>
using namespace std;
int main()
{
int ia[6] = { 27,210,12,47,109,83 };
vector<int, allocator<int>> vi(ia, ia + 6);
//********容器 vector 分配器 allocator********
//vector 4种初始化
//std::vector<int> first; // empty vector of ints
//std::vector<int> second(4, 100); // four ints with value 100
//std::vector<int> third(second.begin(), second.end()); // iterating through second
//std::vector<int> fourth(third); // a copy of third
cout << count_if(vi.begin(), vi.end(), not1(bind2nd(less<int>(), 40))) << endl;
//算法 count_if 迭代器 vi.begin() 仿函数 less 适配器 not1 bind2nd
return 0;
}
容器
- 序列容器
- array
- vector
- deque
- list : 双向链表
- forward_list:单链表
- 排序容器
- set/multiset :红黑树
- map/multimap : 红黑树
- 哈希容器
- unordered_set/unordered_multiset
- unordered_map/unordered_multimap
评论
登录后参与技术讨论,分享你的经验与见解。
登录 / 注册暂无评论