侯捷-STL与泛型编程(GP)笔记

2023-05-16

1.stl体系结构基础介绍
在这里插入图片描述
分配器(allocator):主管分配内存
适配器(adaptor):进行一个转换,与另一个对象绑定

#include<iostream>
#include<algorithm>//算法
#include<functional>//仿函数
#include<vector>//container:向量
using namespace std;
int main()
{
	int ia[6] = { 27,210,12,47,109,83 };
	vector<int, allocator<int>> vi(ia, ia + 6);//容器,分配器
	cout << count_if(vi.begin(), vi.end(),//算法,迭代器,
		not1(bind2nd(less<int>(), 40)));//仿函数适配器,仿函数,
	system("pause");
	return 0;
}

前闭后开区间
在这里插入图片描述

int main()
{
	for (int i : {2, 3, 4, 5, 6, 9, 7})//for(decl:coll)
	{                                 //{     statement      }
		cout << i << endl;
	}
	system("pause");
	return 0;
}

在这里插入图片描述

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

侯捷-STL与泛型编程(GP)笔记 的相关文章

随机推荐

  • 模板template的使用

    函数模板应用实例 C 43 43 与C的不同点 xff1a 模板template的使用 include lt iostream gt 无需加上 34 h 34 using namespace std 使用命名空间 template lt t
  • 时间复杂度与空间复杂度

    时间复杂度与空间复杂度 1 Running time xff1a 时间复杂度 T n 61 O f n 时间复杂度 xff1a 算法执行时间随规模增大而增长的趋势 以算法中重复执行的次数作为算法时间复杂度的依据 计算机科学中 xff0c 算
  • 对抗样本是怎么产生的?如何避免对抗攻击?

    全文共2637字 xff0c 预计学习时长5分钟 图片来源 xff1a pexels 64 pixabay 随着深度神经网络的出现 xff0c 机器学习领域的安全问题日益突出 人们对神经网络的可解释性提出了质疑 xff0c 也自然对深度学习
  • 数组与指针的区别

    数组与指针的区别 1 指针数组与数组指针 int a1 3 It is an array each element is a pointer int a2 3 It is a pointer It points to an array wi
  • while/do while/for/goto的区别

    Calculate 1 43 2 43 3 43 43 100
  • if/switch的区别

  • Function pointer and pointer function指针函数和函数指针

    指针函数 int f int x int y pointer function f is a function it returns a pointer 函数指针 int f int x int y function pointer f i
  • 类的应用示例+继承

    类的应用示例 include lt iostream gt using namespace std 使用命名空间 class student constructor initializer list 构造函数初始化列表 public stu
  • Structure and Class (结构体与类)

  • STL中vector的使用

    STL中vector vector的使用 include lt iostream gt include lt vector gt using namespace std 使用命名空间 int main vector lt int gt v1
  • Fibonacci的四种求解方法

    Fibonacci Sequence的使用 include lt iostream gt using namespace std 使用命名空间 T N 61 O N 2 61 T N 1 43 T N 2 43 2 int fib2 int
  • 最大子序列和问题

    最大子序列和问题Maximum Subsequence Sum include lt iostream gt include lt vector gt using namespace std 使用命名空间 T N 61 O N 3 Cubi
  • C++基础之基础

    C 43 43 xff08 容纳了好几种编程范式 xff09 xff1a 面向对象编程 泛型编程 过程化编程 面向对象编程 xff1a 其本质是以建立模型体现出来的抽象思维过程和面向对象的方法 抽象 继承 多态 xff1a 抽象性是指将具有
  • 这五大MySQL在线课程,最适合初学者的你!

    全文共3214字 xff0c 预计学习时长7分钟 图片来源 xff1a pexels com 64 pixabay 过去几年 xff0c 有句话越来越流行 xff1a 人人必须学习如何编码 这值得鼓励 在当今以信息和技术为中心的世界里 xf
  • 课程作业(单链表C++实现)

    单链表的操作C 43 43 实现 include lt iostream gt using namespace std 使用命名空间 template lt typename dataType gt 定义一个数据类型模板 class lin
  • 课程作业(二叉查找树)

    mainTest cpp include lt iostream gt include 34 binarySearchTree h 34 using namespace std int main cout lt lt 34 请按前序输入一棵
  • C++程序设计实践指导——第一章 简单编程 (2)

    第一章 简单编程 xff08 2 xff09 1 9 统计与替换字符串中的关键字 建立一个类WordNum xff0c 统计一个英文字符串中的英文单词个数 字符串中的各英文单i司以一个或多个空格分隔 如字符串 34 I am a stude
  • STL+Python+图像处理-学习资源

    1 C 43 43 STL学习网站 CPlusPlus com CppReference com gcc gnu org 2 Python学习书籍及网站 Python Crash Course Learn Python the Hard W
  • STL----------C++Primer(笔记)

    1 string string word cin gt gt word getline cin word 关系操作符 lt lt 61 gt gt 61 include lt cctype gt 头文件 string s 61 34 Hel
  • 侯捷-STL与泛型编程(GP)笔记

    1 stl体系结构基础介绍 分配器 xff08 allocator xff09 xff1a 主管分配内存 适配器 xff08 adaptor xff09 xff1a 进行一个转换 xff0c 与另一个对象绑定 include lt iost