第二十五章 STL- 常用算法

概述:

  • 算法主要是由头文件<algorithm> <functional> <numeric>组成。

  • <algorithm>是所有STL头文件中最大的一个,范围涉及到比较、 交换、查找、遍历操作、复制、修改等等

  • <numeric>体积很小,只包括几个在序列上面进行简单数学运算的模板函数

  • <functional>定义了一些模板类,用以声明函数对象。

一、常用遍历算法

学习目标:

  • 掌握常用的遍历算法

算法简介:

  • for_each //遍历容器

  • transform //搬运容器到另一个容器中

1、for_each

功能描述:

  • 实现遍历容器

函数原型:

  • for_each(iterator beg, iterator end, _func);

    // 遍历算法 遍历容器元素

    // beg 开始迭代器

    // end 结束迭代器

    // _func 函数或者函数对象

示例:

 #include <algorithm>#include <vector>​//普通函数void print01(int val) {cout << val << " ";}//函数对象class print02 {public:void operator()(int val) {cout << val << " ";}};​//for_each算法基本用法void test01() {​vector<int> v;for (int i = 0; i < 10; i++) {v.push_back(i);}​//遍历算法for_each(v.begin(), v.end(), print01);cout << endl;​for_each(v.begin(), v.end(), print02());cout << endl;}​int main() {​test01();​system("pause");​return 0;}

总结:for_each在实际开发中是最常用遍历算法,需要熟练掌握

2、transform

功能描述:

  • 搬运容器到另一个容器中

函数原型:

  • transform(iterator beg1, iterator end1, iterator beg2, _func);

//beg1 源容器开始迭代器

//end1 源容器结束迭代器

//beg2 目标容器开始迭代器

//_func 函数或者函数对象

示例:

 #include<vector>#include<algorithm>​//常用遍历算法  搬运 transform​class TransForm{public:int operator()(int val){return val;}​};​class MyPrint{public:void operator()(int val){cout << val << " ";}};​void test01(){vector<int>v;for (int i = 0; i < 10; i++){v.push_back(i);}​vector<int>vTarget; //目标容器​vTarget.resize(v.size()); // 目标容器需要提前开辟空间​transform(v.begin(), v.end(), vTarget.begin(), TransForm());​for_each(vTarget.begin(), vTarget.end(), MyPrint());}​int main() {​test01();​system("pause");​return 0;}

总结: 搬运的目标容器必须要提前开辟空间,否则无法正常搬运

二、常用查找算法

学习目标:

  • 掌握常用的查找算法

算法简介:

  • find //查找元素

  • find_if //按条件查找元素

  • adjacent_find //查找相邻重复元素

  • binary_search //二分查找法

  • count //统计元素个数

  • count_if //按条件统计元素个数

1、find

功能描述:

  • 查找指定元素,找到返回指定元素的迭代器,找不到返回结束迭代器end()

函数原型:

  • find(iterator beg, iterator end, value);

    // 按值查找元素,找到返回指定位置迭代器,找不到返回结束迭代器位置

    // beg 开始迭代器

    // end 结束迭代器

    // value 查找的元素

示例:

 #include <algorithm>#include <vector>#include <string>void test01() {​vector<int> v;for (int i = 0; i < 10; i++) {v.push_back(i + 1);}//查找容器中是否有 5 这个元素vector<int>::iterator it = find(v.begin(), v.end(), 5);if (it == v.end()) {cout << "没有找到!" << endl;}else {cout << "找到:" << *it << endl;}}​class Person {public:Person(string name, int age) {this->m_Name = name;this->m_Age = age;}//重载==bool operator==(const Person& p) {if (this->m_Name == p.m_Name && this->m_Age == p.m_Age) {return true;}return false;}​public:string m_Name;int m_Age;};​void test02() {​vector<Person> v;​//创建数据Person p1("aaa", 10);Person p2("bbb", 20);Person p3("ccc", 30);Person p4("ddd", 40);​v.push_back(p1);v.push_back(p2);v.push_back(p3);v.push_back(p4);​vector<Person>::iterator it = find(v.begin(), v.end(), p2);if (it == v.end()) {cout << "没有找到!" << endl;}else {cout << "找到姓名:" << it->m_Name << " 年龄: " << it->m_Age << endl;}}

总结: 利用find可以在容器中找指定的元素,返回值是迭代器

2、find_if

功能描述:

  • 按条件查找元素

函数原型:

  • find_if(iterator beg, iterator end, _Pred);

    // 按值查找元素,找到返回指定位置迭代器,找不到返回结束迭代器位置

    // beg 开始迭代器

    // end 结束迭代器

    // _Pred 函数或者谓词(返回bool类型的仿函数)

示例:

 #include <algorithm>#include <vector>#include <string>​//内置数据类型class GreaterFive{public:bool operator()(int val){return val > 5;}};​void test01() {​vector<int> v;for (int i = 0; i < 10; i++) {v.push_back(i + 1);}​vector<int>::iterator it = find_if(v.begin(), v.end(), GreaterFive());if (it == v.end()) {cout << "没有找到!" << endl;}else {cout << "找到大于5的数字:" << *it << endl;}}​//自定义数据类型class Person {public:Person(string name, int age){this->m_Name = name;this->m_Age = age;}public:string m_Name;int m_Age;};​class Greater20{public:bool operator()(Person &p){return p.m_Age > 20;}​};​void test02() {​vector<Person> v;​//创建数据Person p1("aaa", 10);Person p2("bbb", 20);Person p3("ccc", 30);Person p4("ddd", 40);​v.push_back(p1);v.push_back(p2);v.push_back(p3);v.push_back(p4);​vector<Person>::iterator it = find_if(v.begin(), v.end(), Greater20());if (it == v.end()){cout << "没有找到!" << endl;}else{cout << "找到姓名:" << it->m_Name << " 年龄: " << it->m_Age << endl;}}​int main() {​//test01();​test02();​system("pause");​return 0;}

总结:find_if按条件查找使查找更加灵活,提供的仿函数可以改变不同的策略

3、adjacent_find

功能描述:

  • 查找相邻重复元素

函数原型:

  • adjacent_find(iterator beg, iterator end);

    // 查找相邻重复元素,返回相邻元素的第一个位置的迭代器

    // beg 开始迭代器

    // end 结束迭代器

示例:

 #include <algorithm>#include <vector>​void test01(){vector<int> v;v.push_back(1);v.push_back(2);v.push_back(5);v.push_back(2);v.push_back(4);v.push_back(4);v.push_back(3);​//查找相邻重复元素vector<int>::iterator it = adjacent_find(v.begin(), v.end());if (it == v.end()) {cout << "找不到!" << endl;}else {cout << "找到相邻重复元素为:" << *it << endl;}}

总结:面试题中如果出现查找相邻重复元素,记得用STL中的adjacent_find算法

4、binary_search

功能描述:

  • 查找指定元素是否存在

函数原型:

  • bool binary_search(iterator beg, iterator end, value);

    // 查找指定的元素,查到 返回true 否则false

    // 注意: 在无序序列中不可用

    // beg 开始迭代器

    // end 结束迭代器

    // value 查找的元素

示例:

 #include <algorithm>#include <vector>​void test01(){vector<int>v;​for (int i = 0; i < 10; i++){v.push_back(i);}//二分查找bool ret = binary_search(v.begin(), v.end(),2);if (ret){cout << "找到了" << endl;}else{cout << "未找到" << endl;}}​int main() {​test01();​system("pause");​return 0;}

总结:二分查找法查找效率很高,值得注意的是查找的容器中元素必须的有序序列

5、count

功能描述:

  • 统计元素个数

函数原型:

  • count(iterator beg, iterator end, value);

    // 统计元素出现次数

    // beg 开始迭代器

    // end 结束迭代器

    // value 统计的元素

示例:

 #include <algorithm>#include <vector>​//内置数据类型void test01(){vector<int> v;v.push_back(1);v.push_back(2);v.push_back(4);v.push_back(5);v.push_back(3);v.push_back(4);v.push_back(4);​int num = count(v.begin(), v.end(), 4);​cout << "4的个数为: " << num << endl;}​//自定义数据类型class Person{public:Person(string name, int age){this->m_Name = name;this->m_Age = age;}bool operator==(const Person & p){if (this->m_Age == p.m_Age){return true;}else{return false;}}string m_Name;int m_Age;};​void test02(){vector<Person> v;​Person p1("刘备", 35);Person p2("关羽", 35);Person p3("张飞", 35);Person p4("赵云", 30);Person p5("曹操", 25);​v.push_back(p1);v.push_back(p2);v.push_back(p3);v.push_back(p4);v.push_back(p5);Person p("诸葛亮",35);​int num = count(v.begin(), v.end(), p);cout << "num = " << num << endl;}int main() {​//test01();​test02();​system("pause");​return 0;}

总结: 统计自定义数据类型时候,需要配合重载 operator==

6、count_if

功能描述:

  • 按条件统计元素个数

函数原型:

  • count_if(iterator beg, iterator end, _Pred);

    // 按条件统计元素出现次数

    // beg 开始迭代器

    // end 结束迭代器

    // _Pred 谓词

示例:

 #include <algorithm>#include <vector>​class Greater4{public:bool operator()(int val){return val >= 4;}};​//内置数据类型void test01(){vector<int> v;v.push_back(1);v.push_back(2);v.push_back(4);v.push_back(5);v.push_back(3);v.push_back(4);v.push_back(4);​int num = count_if(v.begin(), v.end(), Greater4());​cout << "大于4的个数为: " << num << endl;}​//自定义数据类型class Person{public:Person(string name, int age){this->m_Name = name;this->m_Age = age;}​string m_Name;int m_Age;};​class AgeLess35{public:bool operator()(const Person &p){return p.m_Age < 35;}};void test02(){vector<Person> v;​Person p1("刘备", 35);Person p2("关羽", 35);Person p3("张飞", 35);Person p4("赵云", 30);Person p5("曹操", 25);​v.push_back(p1);v.push_back(p2);v.push_back(p3);v.push_back(p4);v.push_back(p5);​int num = count_if(v.begin(), v.end(), AgeLess35());cout << "小于35岁的个数:" << num << endl;}​​int main() {​//test01();​test02();​system("pause");​return 0;}

总结:按值统计用count,按条件统计用count_if

三、常用排序算法

学习目标:

  • 掌握常用的排序算法

算法简介:

  • sort //对容器内元素进行排序

  • random_shuffle //洗牌 指定范围内的元素随机调整次序

  • merge // 容器元素合并,并存储到另一容器中

  • reverse // 反转指定范围的元素

1、sort

功能描述:

  • 对容器内元素进行排序

函数原型:

  • sort(iterator beg, iterator end, _Pred);

    // 按值查找元素,找到返回指定位置迭代器,找不到返回结束迭代器位置

    // beg 开始迭代器

    // end 结束迭代器

    // _Pred 谓词

示例:

 #include <algorithm>#include <vector>​void myPrint(int val){cout << val << " ";}​void test01() {vector<int> v;v.push_back(10);v.push_back(30);v.push_back(50);v.push_back(20);v.push_back(40);​//sort默认从小到大排序sort(v.begin(), v.end());for_each(v.begin(), v.end(), myPrint);cout << endl;​//从大到小排序sort(v.begin(), v.end(), greater<int>());for_each(v.begin(), v.end(), myPrint);cout << endl;}​int main() {​test01();​system("pause");​return 0;}

总结:sort属于开发中最常用的算法之一,需熟练掌握

2、random_shuffle

功能描述:

  • 洗牌 指定范围内的元素随机调整次序

函数原型:

  • random_shuffle(iterator beg, iterator end);

    // 指定范围内的元素随机调整次序

    // beg 开始迭代器

    // end 结束迭代器

示例:

 #include <algorithm>#include <vector>#include <ctime>​class myPrint{public:void operator()(int val){cout << val << " ";}};​void test01(){srand((unsigned int)time(NULL));vector<int> v;for(int i = 0 ; i < 10;i++){v.push_back(i);}for_each(v.begin(), v.end(), myPrint());cout << endl;​//打乱顺序random_shuffle(v.begin(), v.end());for_each(v.begin(), v.end(), myPrint());cout << endl;}​int main() {​test01();​system("pause");​return 0;}

总结:random_shuffle洗牌算法比较实用,使用时记得加随机数种子

3、merge

功能描述:

  • 两个容器元素合并,并存储到另一容器中

函数原型:

  • merge(iterator beg1, iterator end1, iterator beg2, iterator end2, iterator dest);

    // 容器元素合并,并存储到另一容器中

    // 注意: 两个容器必须是有序的

    // beg1 容器1开始迭代器 // end1 容器1结束迭代器 // beg2 容器2开始迭代器 // end2 容器2结束迭代器 // dest 目标容器开始迭代器

示例:

 #include <algorithm>#include <vector>​class myPrint{public:void operator()(int val){cout << val << " ";}};​void test01(){vector<int> v1;vector<int> v2;for (int i = 0; i < 10 ; i++) {v1.push_back(i);v2.push_back(i + 1);}​vector<int> vtarget;//目标容器需要提前开辟空间vtarget.resize(v1.size() + v2.size());//合并  需要两个有序序列merge(v1.begin(), v1.end(), v2.begin(), v2.end(), vtarget.begin());for_each(vtarget.begin(), vtarget.end(), myPrint());cout << endl;}​int main() {​test01();​system("pause");​return 0;}

总结:merge合并的两个容器必须的有序序列

4、reverse

功能描述:

  • 将容器内元素进行反转

函数原型:

  • reverse(iterator beg, iterator end);

    // 反转指定范围的元素

    // beg 开始迭代器

    // end 结束迭代器

示例:

 #include <algorithm>#include <vector>​class myPrint{public:void operator()(int val){cout << val << " ";}};​void test01(){vector<int> v;v.push_back(10);v.push_back(30);v.push_back(50);v.push_back(20);v.push_back(40);​cout << "反转前: " << endl;for_each(v.begin(), v.end(), myPrint());cout << endl;​cout << "反转后: " << endl;​reverse(v.begin(), v.end());for_each(v.begin(), v.end(), myPrint());cout << endl;}​int main() {​test01();​system("pause");​return 0;}

总结:reverse反转区间内元素,面试题可能涉及到

四、常用拷贝和替换算法

学习目标:

  • 掌握常用的拷贝和替换算法

算法简介:

  • copy // 容器内指定范围的元素拷贝到另一容器中

  • replace // 将容器内指定范围的旧元素修改为新元素

  • replace_if // 容器内指定范围满足条件的元素替换为新元素

  • swap // 互换两个容器的元素

1、copy

功能描述:

  • 容器内指定范围的元素拷贝到另一容器中

函数原型:

  • copy(iterator beg, iterator end, iterator dest);

    // 按值查找元素,找到返回指定位置迭代器,找不到返回结束迭代器位置

    // beg 开始迭代器

    // end 结束迭代器

    // dest 目标起始迭代器

示例:

 #include <algorithm>#include <vector>​class myPrint{public:void operator()(int val){cout << val << " ";}};​void test01(){vector<int> v1;for (int i = 0; i < 10; i++) {v1.push_back(i + 1);}vector<int> v2;v2.resize(v1.size());copy(v1.begin(), v1.end(), v2.begin());​for_each(v2.begin(), v2.end(), myPrint());cout << endl;}​int main() {​test01();​system("pause");​return 0;}

总结:利用copy算法在拷贝时,目标容器记得提前开辟空间

2、replace

功能描述:

  • 将容器内指定范围的旧元素修改为新元素

函数原型:

  • replace(iterator beg, iterator end, oldvalue, newvalue);

    // 将区间内旧元素 替换成 新元素

    // beg 开始迭代器

    // end 结束迭代器

    // oldvalue 旧元素

    // newvalue 新元素

示例:

 #include <algorithm>#include <vector>​class myPrint{public:void operator()(int val){cout << val << " ";}};​void test01(){vector<int> v;v.push_back(20);v.push_back(30);v.push_back(20);v.push_back(40);v.push_back(50);v.push_back(10);v.push_back(20);​cout << "替换前:" << endl;for_each(v.begin(), v.end(), myPrint());cout << endl;​//将容器中的20 替换成 2000cout << "替换后:" << endl;replace(v.begin(), v.end(), 20,2000);for_each(v.begin(), v.end(), myPrint());cout << endl;}​int main() {​test01();​system("pause");​return 0;}

总结:replace会替换区间内满足条件的元素

3、replace_if

功能描述:

  • 将区间内满足条件的元素,替换成指定元素

函数原型:

  • replace_if(iterator beg, iterator end, _pred, newvalue);

    // 按条件替换元素,满足条件的替换成指定元素

    // beg 开始迭代器

    // end 结束迭代器

    // _pred 谓词

    // newvalue 替换的新元素

示例:

 #include <algorithm>#include <vector>​class myPrint{public:void operator()(int val){cout << val << " ";}};​class ReplaceGreater30{public:bool operator()(int val){return val >= 30;}​};​void test01(){vector<int> v;v.push_back(20);v.push_back(30);v.push_back(20);v.push_back(40);v.push_back(50);v.push_back(10);v.push_back(20);​cout << "替换前:" << endl;for_each(v.begin(), v.end(), myPrint());cout << endl;​//将容器中大于等于的30 替换成 3000cout << "替换后:" << endl;replace_if(v.begin(), v.end(), ReplaceGreater30(), 3000);for_each(v.begin(), v.end(), myPrint());cout << endl;}​int main() {​test01();​system("pause");​return 0;}

总结:replace_if按条件查找,可以利用仿函数灵活筛选满足的条件

4、swap

功能描述:

  • 互换两个容器的元素

函数原型:

  • swap(container c1, container c2);

    // 互换两个容器的元素

    // c1容器1

    // c2容器2

示例:

 #include <algorithm>#include <vector>​class myPrint{public:void operator()(int val){cout << val << " ";}};​void test01(){vector<int> v1;vector<int> v2;for (int i = 0; i < 10; i++) {v1.push_back(i);v2.push_back(i+100);}​cout << "交换前: " << endl;for_each(v1.begin(), v1.end(), myPrint());cout << endl;for_each(v2.begin(), v2.end(), myPrint());cout << endl;​cout << "交换后: " << endl;swap(v1, v2);for_each(v1.begin(), v1.end(), myPrint());cout << endl;for_each(v2.begin(), v2.end(), myPrint());cout << endl;}​int main() {​test01();​system("pause");​return 0;}

总结:swap交换容器时,注意交换的容器要同种类型

五、常用算术生成算法

学习目标:

  • 掌握常用的算术生成算法

注意:

  • 算术生成算法属于小型算法,使用时包含的头文件为 #include <numeric>

算法简介:

  • accumulate // 计算容器元素累计总和

  • fill // 向容器中添加元素

1、accumulate

功能描述:

  • 计算区间内 容器元素累计总和

函数原型:

  • accumulate(iterator beg, iterator end, value);

    // 计算容器元素累计总和

    // beg 开始迭代器

    // end 结束迭代器

    // value 起始值

示例:

 #include <numeric>#include <vector>void test01(){vector<int> v;for (int i = 0; i <= 100; i++) {v.push_back(i);}​int total = accumulate(v.begin(), v.end(), 0);​cout << "total = " << total << endl;}​int main() {​test01();​system("pause");​return 0;}

总结:accumulate使用时头文件注意是 numeric,这个算法很实用

2、fill

功能描述:

  • 向容器中填充指定的元素

函数原型:

  • fill(iterator beg, iterator end, value);

    // 向容器中填充元素

    // beg 开始迭代器

    // end 结束迭代器

    // value 填充的值

示例:

 #include <numeric>#include <vector>#include <algorithm>​class myPrint{public:void operator()(int val){cout << val << " ";}};​void test01(){​vector<int> v;v.resize(10);//填充fill(v.begin(), v.end(), 100);​for_each(v.begin(), v.end(), myPrint());cout << endl;}​int main() {​test01();​system("pause");​return 0;}

总结:利用fill可以将容器区间内元素填充为 指定的值

六、常用集合算法

学习目标:

  • 掌握常用的集合算法

算法简介:

  • set_intersection // 求两个容器的交集

  • set_union // 求两个容器的并集

  • set_difference // 求两个容器的差集

1、set_intersection

功能描述:

  • 求两个容器的交集

函数原型:

  • set_intersection(iterator beg1, iterator end1, iterator beg2, iterator end2, iterator dest);

    // 求两个集合的交集

    // 注意:两个集合必须是有序序列

    // beg1 容器1开始迭代器 // end1 容器1结束迭代器 // beg2 容器2开始迭代器 // end2 容器2结束迭代器 // dest 目标容器开始迭代器

示例:

 #include <vector>#include <algorithm>​class myPrint{public:void operator()(int val){cout << val << " ";}};​void test01(){vector<int> v1;vector<int> v2;for (int i = 0; i < 10; i++){v1.push_back(i);v2.push_back(i+5);}​vector<int> vTarget;//取两个里面较小的值给目标容器开辟空间vTarget.resize(min(v1.size(), v2.size()));​//返回目标容器的最后一个元素的迭代器地址vector<int>::iterator itEnd = set_intersection(v1.begin(), v1.end(), v2.begin(), v2.end(), vTarget.begin());​for_each(vTarget.begin(), itEnd, myPrint());cout << endl;}​int main() {​test01();​system("pause");​return 0;}

总结:

  • 求交集的两个集合必须的有序序列

  • 目标容器开辟空间需要从两个容器中取小值

  • set_intersection返回值既是交集中最后一个元素的位置

2、set_union

功能描述:

  • 求两个集合的并集

函数原型:

  • set_union(iterator beg1, iterator end1, iterator beg2, iterator end2, iterator dest);

    // 求两个集合的并集

    // 注意:两个集合必须是有序序列

    // beg1 容器1开始迭代器 // end1 容器1结束迭代器 // beg2 容器2开始迭代器 // end2 容器2结束迭代器 // dest 目标容器开始迭代器

示例:

 #include <vector>#include <algorithm>​class myPrint{public:void operator()(int val){cout << val << " ";}};​void test01(){vector<int> v1;vector<int> v2;for (int i = 0; i < 10; i++) {v1.push_back(i);v2.push_back(i+5);}​vector<int> vTarget;//取两个容器的和给目标容器开辟空间vTarget.resize(v1.size() + v2.size());​//返回目标容器的最后一个元素的迭代器地址vector<int>::iterator itEnd = set_union(v1.begin(), v1.end(), v2.begin(), v2.end(), vTarget.begin());​for_each(vTarget.begin(), itEnd, myPrint());cout << endl;}​int main() {​test01();​system("pause");​return 0;}

总结:

  • 求并集的两个集合必须的有序序列

  • 目标容器开辟空间需要两个容器相加

  • set_union返回值既是并集中最后一个元素的位置

3、set_difference

功能描述:

  • 求两个集合的差集

函数原型:

  • set_difference(iterator beg1, iterator end1, iterator beg2, iterator end2, iterator dest);

    // 求两个集合的差集

    // 注意:两个集合必须是有序序列

    // beg1 容器1开始迭代器 // end1 容器1结束迭代器 // beg2 容器2开始迭代器 // end2 容器2结束迭代器 // dest 目标容器开始迭代器

示例:

 #include <vector>#include <algorithm>​class myPrint{public:void operator()(int val){cout << val << " ";}};​void test01(){vector<int> v1;vector<int> v2;for (int i = 0; i < 10; i++) {v1.push_back(i);v2.push_back(i+5);}​vector<int> vTarget;//取两个里面较大的值给目标容器开辟空间vTarget.resize( max(v1.size() , v2.size()));​//返回目标容器的最后一个元素的迭代器地址cout << "v1与v2的差集为: " << endl;vector<int>::iterator itEnd = set_difference(v1.begin(), v1.end(), v2.begin(), v2.end(), vTarget.begin());for_each(vTarget.begin(), itEnd, myPrint());cout << endl;​​cout << "v2与v1的差集为: " << endl;itEnd = set_difference(v2.begin(), v2.end(), v1.begin(), v1.end(), vTarget.begin());for_each(vTarget.begin(), itEnd, myPrint());cout << endl;}​int main() {​test01();​system("pause");​return 0;}

总结:

  • 求差集的两个集合必须的有序序列

  • 目标容器开辟空间需要从两个容器取较大值

  • set_difference返回值既是差集中最后一个元素的位置

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/226815.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

JS中的String常用的实例方法

splice():分隔符 把字符串以分隔符的形式拆分为数组 const str pink,red;const arr str.split(,);console.log(arr);//Array[0,"pink";1:"red"]const str1 2022-4-8;const arr1 str1.split(-);console.log(arr1);//Array[0,"2022";1:"…

Vue3快速上手笔记

Vue3快速上手 1.Vue3简介 2020年9月18日&#xff0c;Vue.js发布3.0版本&#xff0c;代号&#xff1a;One Piece&#xff08;海贼王&#xff09;耗时2年多、2600次提交、30个RFC、600次PR、99位贡献者github上的tags地址&#xff1a;https://github.com/vuejs/vue-next/release…

实操Nginx(七层代理)+Tomcat多实例部署,实现负载均衡和动静分离

目录 Tomcat多实例部署&#xff08;192.168.17.27&#xff09; 1.安装jdk&#xff0c;设置jdk的环境变量 2.安装tomcat在一台已经部署了tomcat的机器上复制tomcat的配置文件取名tomcat1 ​编辑 编辑配置文件更改端口号&#xff0c;将端口号改为8081 启动 tomcat&#xff…

SpringBoot之响应的详细解析

2. 响应 前面我们学习过HTTL协议的交互方式&#xff1a;请求响应模式&#xff08;有请求就有响应&#xff09; 那么Controller程序呢&#xff0c;除了接收请求外&#xff0c;还可以进行响应。 2.1 ResponseBody 在我们前面所编写的controller方法中&#xff0c;都已经设置了…

Linux面试题精选:提升你的面试准备

大家有关于JavaScript知识点不知道可以去 &#x1f389;博客主页&#xff1a;阿猫的故乡 &#x1f389;系列专栏&#xff1a;JavaScript专题栏 &#x1f389;ajax专栏&#xff1a;ajax知识点 &#x1f389;欢迎关注&#xff1a;&#x1f44d;点赞&#x1f64c;收藏✍️留言 学习…

CD8+T细胞通过NKG2D-NKG2DL轴维持对MHC-I阴性肿瘤细胞的杀伤

今天给同学们分享一篇实验文章“CD8 T cells maintain killing of MHC-I-negative tumor cells through the NKG2D-NKG2DL axis”&#xff0c;这篇文章发表在Nat Cancer期刊上&#xff0c;影响因子为22.7。 结果解读&#xff1a; MHC-I阴性肿瘤的免疫疗法需要CD8 T细胞 作者先…

下午好~ 我的论文【yolo1~4】(第二期)

写在前面&#xff1a;本来是一期的&#xff0c;我看了太多内容了&#xff0c;于是分成三期发吧 TAT &#xff08;捂脸&#xff09; 文章目录 YOLO系列v1v2v3v4 YOLO系列 v1 You Only Look Once: Unified, Real-Time Object Detection 2015 ieee computer society 12.3 CCF-C…

高云GW1NSR-4C开发板M3核串口通信

1.PLLVR频率计算 高云的M3核要用到PLLVR核&#xff0c;其输出频率FCLKIN*(FBDIV_SEL1)/(IDIV_SEL1)&#xff0c;但同时要满足FCLKIN*(FBDIV_SEL1)*ODIV_SEL)/(IDIV_SEL1)的值在600MHz和1200MHz之间。例如官方示例&#xff0c;其输入频率FCLKIN50MHz&#xff0c;要输出80MHz&am…

appium2.0.1安装完整教程+uiautomator2安装教程

第一步&#xff1a;根据官网命令安装appium&#xff08;Install Appium - Appium Documentation&#xff09; 注意npm前提是设置淘宝镜像&#xff1a; npm config set registry https://registry.npmmirror.com/ 会魔法的除外。。。 npm i --locationglobal appium或者 npm…

C语言面试之旅:掌握基础,探索深度(面试实战之单片机指令系统)

一、概述 单片机指令系统是单片机硬件设计的重要组成部分&#xff0c;它决定了单片机能够执行什么样的操作。指令系统通常由一系列二进制代码指令组成&#xff0c;这些指令可用于对单片机内部的各个寄存器进行操作&#xff0c;或者对内存中的数据进行读写。了解单片机的指令系统…

oracle DG 三种应用机制

首先理解不管是哪种机制&#xff0c;oracle都不是从主库直接传归档文件到备库&#xff0c;而是通过网络将主库的redo数据传输到备库&#xff1a; 1、普通DG是主库发生日志切换&#xff0c;备库把接收到的redo数据在备库通过归档进程生成为归档文件进行应用 2、ADG则是备库把接收…

Java技术栈 —— 微服务框架Spring Cloud —— Ruoyi-Cloud 学习(二)

RuoYi项目开发过程 一、登录功能(鉴权模块)1.1 后端部分1.1.1 什么是JWT?1.1.2 什么是Base64?为什么需要它&#xff1f;1.1.3 SpringBoot注解解析1.1.4 依赖注入和控制反转1.1.5 什么是Restful?1.1.6 Log4j 2、Logpack、SLF4j日志框架1.1.7 如何将项目打包成指定bytecode字节…

基于springboot的教学在线作业管理系统(源码+调试)

项目描述 临近学期结束&#xff0c;还是毕业设计&#xff0c;你还在做java程序网络编程&#xff0c;期末作业&#xff0c;老师的作业要求觉得大了吗?不知道毕业设计该怎么办?网页功能的数量是否太多?没有合适的类型或系统?等等。你想解决的问题&#xff0c;今天给大家介绍…

性能提升100%、存储节约50%!猕猴桃游戏搭载OceanBase开启云端手游新篇章

近日&#xff0c;武汉灵动在线科技有限公司&#xff08;以下简称“灵动在线”&#xff09;与 OceanBase 达成合作&#xff0c;旗下品牌猕猴桃游戏的“游戏用户中心&#xff08;微信小程序&#xff09;”和“BI 分析报表业务系统“两大关键业务系统全面接入 OB Cloud 云数据库&a…

windows下redis 设置开机自启动

1&#xff0c;在redis的目录下执行&#xff08;执行后就作为windows服务了&#xff09; redis-server --service-install redis.windows.conf 2&#xff0c;安装好后需要手动启动redis redis-server --service-start 3&#xff0c;停止服务 redis-server --service-stop

用标记接口定义类型

标记接口是不含有任何方法的接口&#xff0c;它的目的是通过将特定接口应用于类来为该类添加类型信息。以下是一个示例&#xff1a; public interface Drawable {// 标记接口&#xff0c;不包含任何方法 }public class Circle implements Drawable {private int radius;public…

C# 加载本地文件设置应用程序图标

static class Program{[STAThread]static void Main(){Application.EnableVisualStyles();Application.SetCompatibleTextRenderingDefault(false);Form mainForm new Form1();mainForm.Show();//IntPtr hProcess Process.GetCurrentProcess().MainWindowHandle;// 设置应用程…

【C++11特性篇】利用 { } 初始化(1)

前言 大家好吖&#xff0c;欢迎来到 YY 滴C系列 &#xff0c;热烈欢迎&#xff01; 本章主要内容面向接触过C的老铁 主要内容含&#xff1a; 欢迎订阅 YY滴C专栏&#xff01;更多干货持续更新&#xff01;以下是传送门&#xff01; 目录 一.回顾C98标准中{}的使用二.一切皆可用…

大创项目推荐 垃圾邮件(短信)分类算法实现 机器学习 深度学习

文章目录 0 前言2 垃圾短信/邮件 分类算法 原理2.1 常用的分类器 - 贝叶斯分类器 3 数据集介绍4 数据预处理5 特征提取6 训练分类器7 综合测试结果8 其他模型方法9 最后 0 前言 &#x1f525; 优质竞赛项目系列&#xff0c;今天要分享的是 &#x1f6a9; 垃圾邮件(短信)分类算…

TrustZone之中断及中断处理

一、中断 接下来,我们将查看系统中的中断,如下图所示: 通用中断控制器(GIC)支持TrustZone。每个中断源,在GIC规范中称为INTID,分配到以下三个组之一: • Group0:安全中断,以FIQ方式发出信号 • 安全Group1:安全中断,以IRQ或FIQ方式发出信号 • 非安全Gr…