摘要: 1.仿函数 /* 仿函数:让类的对象模仿函数调用的行为(函数名()) //对象() 关键点在于重载() 仿函数一般来说用来做比较准则 充当for_each的参数 No.1 自己写仿函数 */ class Sum { public: int operator()(const int a, const 阅读全文
posted @ 2021-09-10 19:29 Creature_lurk 阅读(37) 评论(0) 推荐(0) 编辑
摘要: 1.迭代器 迭代器:可以说是一种访问容器的一个桥梁,类中类的一个对象,去模仿指针的行为 迭代器分类: 按照定义方式分类: + 正向迭代器: + 容器名::iterator iter; + begin(); + end(); + 常量正向迭代器 + 容器名::const_iterator citer 阅读全文
posted @ 2021-09-10 19:23 Creature_lurk 阅读(58) 评论(0) 推荐(0) 编辑
摘要: 1.initalizer_list(列表) template <class _Ty> class MyVector { public: MyVector(int size) :curSize(0) { dataMemory = new _Ty[size]; } MyVector(initialize 阅读全文
posted @ 2021-09-10 19:04 Creature_lurk 阅读(24) 评论(0) 推荐(0) 编辑
摘要: 1.tuple /* 可变参模板类 参数个数、数据类型不限定 */ void testCreateTuple() { //正常创建 tuple<int, string, double, float, int> tup1; tuple<int, string, string, double> tup2 阅读全文
posted @ 2021-09-10 18:58 Creature_lurk 阅读(26) 评论(0) 推荐(0) 编辑
摘要: 1.map(映射) /* map:映射,一种对应关系 自带排序(按照键去排序) 键唯一,相同键采用最后一次插入的数据,覆盖的方式去处理 存储的数据是: 数对类型(pair) */ void testMap() { map<int, string>str; //1.pair对象插入 str.inser 阅读全文
posted @ 2021-09-09 19:53 Creature_lurk 阅读(32) 评论(0) 推荐(0) 编辑
摘要: 1.set /* set:集合 1.1 不允许出现重复的数据,插入重复的只会存在一个 1.2 插入数据后,数据排好序,默认情况是从从小到大 No.1 set基本操作 No.2 处理自定义类型 */ void testSet() { set<string> s; s.insert("data1"); 阅读全文
posted @ 2021-09-09 16:11 Creature_lurk 阅读(26) 评论(0) 推荐(0) 编辑
摘要: 1.优先队列((priority_queue) void testCreatePriority_queue() { //最完整创建方式 //1.存储的数据类型 int //2.底层实现的容器类型 vector<int> //3.排序准则 less<int> greater<int> priority 阅读全文
posted @ 2021-09-08 21:20 Creature_lurk 阅读(31) 评论(0) 推荐(0) 编辑
摘要: 1.双向队列(deque) void testDeque() { deque<int> data; data.push_back(1); data.push_front(2); data.push_back(3); cout << data.size() << endl; while (!data. 阅读全文
posted @ 2021-09-08 21:13 Creature_lurk 阅读(28) 评论(0) 推荐(0) 编辑
摘要: 1.队列 先进先出 /* push(); pop(); front(); size(); empty(); */ using namespace std; void testQueue() { queue<string> strQue; strQue.push("Love"); strQue.pus 阅读全文
posted @ 2021-09-08 21:08 Creature_lurk 阅读(26) 评论(0) 推荐(0) 编辑
摘要: 1.stack 后进先出 /* 1.基本操作 push(); pop(); top(); size(); empty(); */ void testStack() { stack<int> s; for (int i = 0; i < 10; i++) { s.push(i); } cout << 阅读全文
posted @ 2021-09-08 20:40 Creature_lurk 阅读(24) 评论(0) 推荐(0) 编辑