C++从入门到精通 第十六章(STL常用算法)

 写在前面:

  1. 本系列专栏主要介绍C++的相关知识,思路以下面的参考链接教程为主,大部分笔记也出自该教程,笔者的原创部分主要在示例代码的注释部分。
  2. 除了参考下面的链接教程以外,笔者还参考了其它的一些C++教材(比如计算机二级教材和C语言教材),笔者认为重要的部分大多都会用粗体标注(未被标注出的部分可能全是重点,可根据相关部分的示例代码量和注释量判断,或者根据实际经验判断)。
  3. 如有错漏欢迎指出。

参考教程:黑马程序员匠心之作|C++教程从0到1入门编程,学习编程不再难_哔哩哔哩_bilibili

一、概述

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

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

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

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

二、常用遍历算法

1、算法简介

for_each    //遍历容器

transform   //将容器中的元素搬运到另一个容器中

2、for_each

for_each(iterator beg, iterator end, _func);    //遍历容器

// beg——开始迭代器

// end——结束迭代器

// _func——函数或者函数对象

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;void print01(int val)
{cout << val << "  ";
}
class print02
{
public:void operator()(int val){cout << val << "  ";}
};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;
}

3、transform

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

// beg1——源容器开始迭代器

// end1——源容器结束迭代器

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

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;class Transform
{
public:int operator()(int v){return v;   //可以对v做运算,比如v+100}
};
class Print
{
public:void operator()(int v){cout << v << "  ";}
};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(), Print());cout << endl;
}int main() {test01();system("pause");return 0;
}

三、常用查找算法

1、算法简介

find //查找元素

find_if //按条件查找元素

adjacent_find //查找相邻重复元素

binary_search //二分查找法

count //统计元素个数

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

//_func 函数或者函数对象

2、find

(1)功能描述:查找指定元素,找到返回指定元素的迭代器,找不到则返回结束迭代器end()。

(2)函数原型:

find(iterator beg, iterator end, value);  

// beg——开始迭代器

// end——结束迭代器

// value——查找的元素

#include<iostream>
using namespace std;
#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;}
}int main() {test01();test02();system("pause");return 0;
}

3、find_if

(1)功能描述:按条件查找元素,找到返回指定位置迭代器,找不到返回结束迭代器位置。

(2)函数原型:

find_if(iterator beg, iterator end, _Pred);   

// beg——开始迭代器

// end——结束迭代器

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

#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;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);}vector<int>::iterator it;it = find_if(v.begin(), v.end(), GreaterFive());if (it == v.end()){cout << "没有找到大于5的数" << endl;}else{cout << *it << endl;}
}class Person
{
public:int m_Age;string m_Name;Person(int age, string name){this->m_Age = age;this->m_Name = name;}
};
class Greater20
{
public:bool operator()(Person &p){return p.m_Age > 20;}
};
void test02()
{vector<Person>v;Person p1(10 ,"aaa");Person p2(20 ,"bbb");Person p3(30 ,"ccc");Person p4(40 ,"ddd");v.push_back(p1);v.push_back(p2);v.push_back(p3);v.push_back(p4);vector<Person>::iterator it;it = find_if(v.begin(), v.end(), Greater20());if (it == v.end()){cout << "没有找到年龄大于20的人" << endl;}else{cout << "找到力" << endl;}
}int main() {test01();test02();system("pause");return 0;
}

4、adjacent_find

(1)功能描述:查找相邻重复元素,返回相邻元素的第一个位置的迭代器。

(2)函数原型:

adjacent_find(iterator beg, iterator end);   

// beg——开始迭代器

// end——结束迭代器

#include<iostream>
using namespace std;
#include<algorithm>
#include<vector>void test01() 
{vector<int> v;v.push_back(0);v.push_back(2);v.push_back(0);v.push_back(3);v.push_back(1);v.push_back(4);v.push_back(3);v.push_back(3);v.push_back(0);vector<int>::iterator it;it = adjacent_find(v.begin(), v.end());if (it == v.end()){cout << "未找到相邻重复元素" << endl;}else{cout << "找到相邻重复元素" << *it << endl;}
}int main() {test01();system("pause");return 0;
}

5、binary_search

(1)功能描述:查找指定元素是否存在,查到就返回true,否则返回false。

(2)函数原型:

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

// beg——开始迭代器

// end——结束迭代器

// value——查找的元素

// 注意: 虽然它查找效率高,但是在无序序列中不可用

#include<iostream>
using namespace std;
#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(), 9);if (ret){cout << "找到元素9" << endl;}else{cout << "未找到元素9" << endl;}
}int main() {test01();system("pause");return 0;
}

6、count

(1)功能描述:统计元素个数(统计元素出现次数)。

(2)函数原型:

count(iterator beg, iterator end, value);  

// beg——开始迭代器

// end——结束迭代器

// value——统计的元素

#include<iostream>
using namespace std;
#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);cout << "4元素个数为" << count(v.begin(), v.end(), 4) << endl;
}class Person
{
public:int m_Age;int m_Age2;Person(int a1, int a2){m_Age = a1;m_Age2 = a2;}bool operator==(const Person &p){if (m_Age2 == p.m_Age2){return true;}else{return false;}}
};
void test02()
{vector<Person>v;Person p1(1, 10);Person p2(1, 10);Person p3(2, 10);Person p4(1, 20);v.push_back(p1);v.push_back(p2);v.push_back(p3);v.push_back(p4);cout << "与p1同Age2的人数为" << count(v.begin(), v.end(), p1)-1 << endl;
}int main() 
{test01();test02();system("pause");return 0;
}

7、count_if

(1)功能描述:按条件统计元素个数(元素出现次数)。

(2)函数原型:

count_if(iterator beg, iterator end, _Pred);  

// beg——开始迭代器

// end——结束迭代器

// _Pred——谓词

#include<iostream>
using namespace std;
#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(6);v.push_back(5);v.push_back(3);v.push_back(4);v.push_back(4);cout << "大于4的元素个数为" << count_if(v.begin(), v.end(), Greater4()) << endl;
}class Person
{
public:int m_Age;int m_Age2;Person(int a1, int a2){m_Age = a1;m_Age2 = a2;}bool operator==(const Person &p){if (p.m_Age2 == m_Age2){return true;}return false;}
};
class Greater15
{
public:bool operator()(const Person &p){return p.m_Age2 > 15;}
};
void test02()
{vector<Person>v;Person p1(1, 10);Person p2(1, 10);Person p3(2, 30);Person p4(1, 20);v.push_back(p1);v.push_back(p2);v.push_back(p3);v.push_back(p4);cout << "Age2>15的人数为" << count_if(v.begin(), v.end(), Greater15()) << endl;
}int main() 
{test01();test02();system("pause");return 0;
}

四、常用排序算法

1、算法简介

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

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

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

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

2、sort

(1)功能描述:对容器内元素进行排序。

(2)函数原型:

sort(iterator beg, iterator end, _Pred);  

// beg——开始迭代器

// end——结束迭代器

// _Pred——谓词

#include<iostream>
using namespace std;
#include<algorithm>
#include<vector>void myPrint(int val)
{cout << val << " ";
}void test01() 
{vector<int> v;v.push_back(1);v.push_back(2);v.push_back(6);v.push_back(5);v.push_back(3);v.push_back(4);v.push_back(4);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;
}

3、random_shuffle

(1)功能描述:洗牌,指定范围内的元素随机调整次序。

(2)函数原型:

random_shuffle(iterator beg, iterator end);    

// beg——开始迭代器

// end——结束迭代器

#include<iostream>
using namespace std;
#include<algorithm>
#include<vector>
#include<ctime>void myPrint(int val)
{cout << val << " ";
}void test01() 
{vector<int> v;v.push_back(1);v.push_back(2);v.push_back(6);v.push_back(5);v.push_back(3);v.push_back(4);v.push_back(4);sort(v.begin(), v.end());              //升序排列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() 
{srand((unsigned int)time(NULL));test01();system("pause");return 0;
}

4、merge

(1)功能描述:两个容器元素合并,并存储到另一容器中(两个容器必须是有序的)。

(2)函数原型:

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

// begx——容器x的开始迭代器

// endx——容器x的结束迭代器

// dest——目标容器的开始迭代器

#include<iostream>
using namespace std;
#include<algorithm>
#include<vector>void myPrint(int val)
{cout << val << " ";
}void test01() 
{vector<int> v;vector<int> v2;for (int i = 0; i < 10; i++){v.push_back(i);v2.push_back(i + 1);}vector<int>v3;v3.resize(v.size() + v2.size());   //提前给目标容器分配空间merge(v.begin(), v.end(), v2.begin(), v2.end(), v3.begin());for_each(v3.begin(), v3.end(), myPrint);cout << endl;
}int main() 
{test01();system("pause");return 0;
}

5、reverse

(1)功能描述:将容器内指定范围的元素进行反转。

(2)函数原型:

reverse(iterator beg, iterator end);     

// beg——开始迭代器

// end——结束迭代器

#include<iostream>
using namespace std;
#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(20);v.push_back(50);v.push_back(40);for_each(v.begin(), v.end(), myPrint);cout << endl;reverse(v.begin(), v.end());   //首尾对调(反转)for_each(v.begin(), v.end(), myPrint);cout << endl;
}int main() 
{test01();system("pause");return 0;
}

五、常用拷贝和替换算法

1、算法简介

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

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

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

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

2、copy

(1)功能描述:容器内指定范围的元素拷贝到另一容器中。

(2)函数原型:

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

// beg——开始迭代器

// end——结束迭代器

// dest——目标容器的起始迭代器

#include<iostream>
using namespace std;
#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(20);v.push_back(50);v.push_back(40);vector<int>v2;v2.resize(v.size());copy(v.begin(), v.end(), v2.begin());for_each(v2.begin(), v2.end(), myPrint);cout << endl;
}int main() 
{test01();system("pause");return 0;
}

3、replace

(1)功能描述:将容器内指定范围的旧元素修改为新元素。

(2)函数原型:

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

// beg——开始迭代器

// end——结束迭代器

// oldvalue——旧元素

// newvalue——新元素

#include<iostream>
using namespace std;
#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(20);v.push_back(50);v.push_back(40);v.push_back(20);replace(v.begin(), v.end(), 20, 60);for_each(v.begin(), v.end(), myPrint);cout << endl;
}int main() 
{test01();system("pause");return 0;
}

4、replace_if

(1)功能描述:将区间内满足条件的元素,替换成指定元素。

(2)函数原型:

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

// beg——开始迭代器

// end——结束迭代器

// _pred——谓词

// newvalue——新元素

#include<iostream>
using namespace std;
#include<algorithm>
#include<vector>void myPrint(int val)
{cout << val << " ";
}class Greater25
{
public:bool operator()(int val){return val > 25;   //大于25的元素全部替换为60}
};
void test01() 
{vector<int> v;v.push_back(10);v.push_back(30);v.push_back(20);v.push_back(50);v.push_back(40);v.push_back(20);replace_if(v.begin(), v.end(), Greater25(), 60);for_each(v.begin(), v.end(), myPrint);cout << endl;
}int main() 
{test01();system("pause");return 0;
}

5、swap

(1)功能描述:互换两个容器的元素(交换的容器元素类型要相同)。

(2)函数原型:

swap(container c1, container c2);    

// c1——容器1

// c2——容器2

#include<iostream>
using namespace std;
#include<algorithm>
#include<vector>void myPrint(int val)
{cout << val << " ";
}void test01() 
{vector<int> v;vector<int> v2;for (int i = 0; i < 10; i++){v.push_back(i);v2.push_back(i + 100);}for_each(v.begin(), v.end(), myPrint);cout << endl;for_each(v2.begin(), v2.end(), myPrint);cout << endl;cout << "-----------------------" << endl;v.swap(v2);for_each(v.begin(), v.end(), myPrint);cout << endl;for_each(v2.begin(), v2.end(), myPrint);cout << endl;
}int main() 
{test01();system("pause");return 0;
}

六、常用算术生成算法

1、算法简介

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

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

fill         //向容器中添加元素

2、accumulate

(1)功能描述:计算区间内容器元素累计总和。

(2)函数原型:

accumulate(iterator beg, iterator end, value);   

// beg——开始迭代器

// end——结束迭代器

// value——起始值

#include<iostream>
using namespace std;
#include<algorithm>
#include<vector>
#include<numeric>void test01() 
{vector<int> v;for (int i = 0; i <= 100; i++){v.push_back(i);}cout << accumulate(v.begin(), v.end(), 1000) << endl;   //1000 + 容器v中元素的总和
}int main() 
{test01();system("pause");return 0;
}

3、fill

(1)功能描述:向容器中填充指定的元素。

(2)函数原型:

fill(iterator beg, iterator end, value);  

// beg——开始迭代器

// end——结束迭代器

// value——填充值

#include<iostream>
using namespace std;
#include<algorithm>
#include<vector>
#include<numeric>void myPrint(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);
}int main() 
{test01();system("pause");return 0;
}

七、常用集合算法

1、算法简介

set_intersection  //求两个容器的交集

set_union       //求两个容器的并集

set_difference   //求两个容器的差集

2、set_intersection

(1)功能描述:求两个容器的交集(两个集合必须是有序序列),返回值是交集中最后一个元素的位置。

(2)函数原型:

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

// begx——容器x的开始迭代器

// endx——容器x的结束迭代器

// dest——目标容器的开始迭代器

#include<iostream>
using namespace std;
#include<algorithm>
#include<vector>
#include<numeric>void myPrint(int val)
{cout << val << " ";
}void test01() 
{vector<int> v1;vector<int> v2;for (int i = 0; i < 10; i++){v1.push_back(i);     //0-9v2.push_back(i + 5); //5-14}vector<int> v3;v3.resize(min(v1.size(), v2.size()));vector<int>::iterator itEnd = set_intersection(v1.begin(), v1.end(), v2.begin(), v2.end(), v3.begin());for_each(v3.begin(), itEnd, myPrint);   //输出的是交集cout << endl;for_each(v3.begin(), v3.end(), myPrint);  //给v3开辟空间时可能会有多余cout << endl;
}int main() 
{test01();system("pause");return 0;
}

3、set_union

(1)功能描述:求两个集合的并集(两个集合必须是有序序列),返回值是并集中最后一个元素的位置。

(2)函数原型:

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

// begx——容器x的开始迭代器

// endx——容器x的结束迭代器

// dest——目标容器的开始迭代器

//目标容器需要开辟的空间大小为两个容器空间的相加结果

#include<iostream>
using namespace std;
#include<algorithm>
#include<vector>
#include<numeric>void myPrint(int val)
{cout << val << " ";
}void test01() 
{vector<int> v1;vector<int> v2;for (int i = 0; i < 10; i++){v1.push_back(i);     //0-9v2.push_back(i + 5); //5-14}vector<int> v3;v3.resize(v1.size() + v2.size());vector<int>::iterator itEnd = set_union(v1.begin(), v1.end(), v2.begin(), v2.end(), v3.begin());for_each(v3.begin(), itEnd, myPrint);   //输出的是并集cout << endl;for_each(v3.begin(), v3.end(), myPrint);  //给v3开辟空间时可能会有多余cout << endl;
}int main() 
{test01();system("pause");return 0;
}

4、set_difference

(1)功能描述:求两个集合的差集(两个集合必须是有序序列),返回值是差集中最后一个元素的位置。

(2)函数原型:

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

// begx——容器x的开始迭代器

// endx——容器x的结束迭代器

// dest——目标容器的开始迭代器

//目标容器需要开辟的空间大小为两个容器空间的较大值

#include<iostream>
using namespace std;
#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;
}

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

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

相关文章

MyBatis--02-1- MybatisPlus----条件构造器

提示&#xff1a;文章写完后&#xff0c;目录可以自动生成&#xff0c;如何生成可参考右边的帮助文档 文章目录 前言AbstractWrapper 条件构造器官网文档https://baomidou.com/pages/10c804/#abstractwrapper](https://baomidou.com/pages/10c804/#abstractwrapper)![在这里插入…

安全这么卷了吗?北京,渗透,4k,不包吃住,非实习

起初某HR找人发了条招聘信息 看到被卷到4k一个月被震惊到了 随后发布了朋友圈&#xff0c;引起来众多讨论 对此网友发表众多评价 越来越卷的工作现象确实是一个普遍存在的问题 另外&#xff0c;也可以考虑和雇主沟通&#xff0c; 寻求更合理的工作安排&#xff0c; 或者…

[ 2024春节 Flink打卡 ] -- Paimon

2024&#xff0c;游子未归乡。工作需要&#xff0c;flink coding。觉知此事要躬行&#xff0c;未休&#xff0c;特记 Flink 社区希望能够将 Flink 的 Streaming 实时计算能力和 Lakehouse 新架构优势进一步结合&#xff0c;推出新一代的 Streaming Lakehouse 技术&#xff0c;…

python53-Python流程控制if条件的类型

从前面的示例可以看到&#xff0c;Python 执行if语句时&#xff0c;会判断if条件是True还是False。那么if条件是不是只能使用 bool类型的表达式呢?不是。if条件可以是任意类型&#xff0c;当下面的值作为 bool表达式时&#xff0c;会被解释器当作False处理。 False、None、0、…

Elasticsearch 去重后求和

标题的要求可以用如下 SQL 表示 select sum(column2) from (select distinct(column1),column2 from table)t 要如何用 DSL 实现呢&#xff0c;先准备下索引和数据 PUT test_index {"mappings": {"properties": {"column1": {"type"…

springboot访问webapp下的jsp页面

一&#xff0c;项目结构。 这是我的项目结构&#xff0c;jsp页面放在WEB-INF下的page目录下面。 二&#xff0c;file--->Project Structure,确保这两个地方都是正确的&#xff0c;确保Source Roots下面有webapp这个目录&#xff08;正常来说&#xff0c;应该本来就有&#…

前端处理过滤,特殊字符以及输入法特殊表情符号emoji的正则方法

问题描述 输入法输入表情或特殊符号&#xff0c;存入数据库时&#xff0c;会发现有报错&#xff0c;因为UTF-8编码有可能是两个、三个、四个字节。Emoji表情是4个字节&#xff0c;而MySQL的utf8编码最多3个字节&#xff0c;所以数据插不进去。 解决方法 前端处理方法 思路使…

目标追踪(tracking)简介

目标追踪是指通过计算机视觉技术&#xff0c;检测和追踪视频或图像中的特定目标的位置和动态变化。目标可以是人、车辆、动物或其他感兴趣的物体。目标追踪在许多领域都具有广泛的应用&#xff0c;如安防监控、交通监管、自动驾驶、虚拟现实等。 目标追踪通常涉及以下几个步骤…

Python in Visual Studio Code 2024年2月发布

排版&#xff1a;Alan Wang 我们很高兴地宣布 2024 年 2 月版 Visual Studio Code 的 Python 和 Jupyter 扩展已经推出&#xff01; 此版本包括以下公告&#xff1a; 默认安装的 Python 调试器扩展快速选择 Python 解释器中的“Create Environment”选项Jupyter 的内置变量查…

flink反压

flink反压&#xff08;backpressure&#xff09;&#xff0c;简单来说就是当接收方的接收速率低于发送方的发送速率&#xff0c;这时如果不做处理就会导致接收方的数据积压越来越多直到内存溢出&#xff0c;所以此时需要一个机制来根据接收方的状态反过来限制发送方的发送速率&…

Spring6学习技术|IoC|手写IoC

学习材料 尚硅谷Spring零基础入门到进阶&#xff0c;一套搞定spring6全套视频教程&#xff08;源码级讲解&#xff09; 有关反射的知识回顾 IoC是基于反射机制实现的。 Java反射机制是在运行状态中&#xff0c;对于任意一个类&#xff0c;都能够知道这个类的所有属性和方法&…

Linux 命令行的世界 :4.操作文件和目录

此时此刻&#xff0c;我们已经准备好了做些真正的工作&#xff01;这一章节将会介绍以下命令&#xff1a; • cp —复制文件和目录 • mv —移动/重命名文件和目录 • mkdir —创建目录 • rm —删除文件和目录 • ln —创建硬链接和符号链接 图形文件管理器能轻松地实现…

网页数据的解析提取(正则表达式----re库详解)

前面&#xff0c;我们已经可以用requests库来获取网页的源代码&#xff0c;得到HTML代码。但我们真正想要的数据是包含在HTML代码之中的。要怎样才能从HTML代码中获取想要的信息呢&#xff1f;正则表达式是一个万能的方法&#xff01;&#xff01;&#xff01; 目录 正则表达…

多维时序 | Matlab实现基于VMD-DBO-GRU、VMD-GRU、GRU的多变量时间序列预测

多维时序 | Matlab实现基于VMD-DBO-GRU、VMD-GRU、GRU的多变量时间序列预测 目录 多维时序 | Matlab实现基于VMD-DBO-GRU、VMD-GRU、GRU的多变量时间序列预测预测效果基本介绍程序设计参考资料 预测效果 基本介绍 Matlab实现基于VMD-DBO-GRU、VMD-GRU、GRU的多变量时间序列预测…

辽宁博学优晨教育:视频剪辑培训,开启创意新篇章

在数字化时代&#xff0c;视频已成为信息传播的重要载体。辽宁博学优晨教育紧跟时代步伐&#xff0c;推出全新的视频剪辑培训课程&#xff0c;为广大学员开启创意之旅&#xff0c;探索视频剪辑的无限可能。 一、视频剪辑&#xff1a;时代的选择与技能的进阶 随着互联网的普及和…

Stable diffusion UI 介绍-文生图

1.提示词&#xff1a; 你希望图中有什么东西 2.负面提示词&#xff1a;你不希望图中有什么东西 选用了什么模型 使用参数 1.采样器 sampling method 使用什么算法进行采样 2.采样迭代步数 sampling steps 生成图像迭代的步数&#xff0c;越多越好&#xff0c;但是生成速度越大越…

【C语言】socket 层到网络接口的驱动程序之间的函数调用过程

一、socket 层到网络接口的驱动程序之间的函数调用过程概述 在 Linux 操作系统中&#xff0c;socket 层到网络接口的驱动程序之间的函数调用过程相对复杂&#xff0c;涉及多个层次的交互。以下是一个简化的概述&#xff0c;描述数据从 socket 传递到硬件驱动&#xff0c;再到硬…

uniapp播放mp4省流方案

背景&#xff1a; 因为项目要播放一个宣传和讲解视频&#xff0c;视频文件过大&#xff0c;同时还为了节省存储流量&#xff0c;想到了一个方案&#xff0c;用m3u8切片替代mp4。 m3u8&#xff1a;切片播放&#xff0c;可以理解为一个1G的视频文件&#xff0c;自行设置文…

【微服务生态】Dubbo

文章目录 一、概述二、Dubbo环境搭建-docker版三、Dubbo配置四、高可用4.1 zookeeper宕机与dubbo直连4.2 负载均衡 五、服务限流、服务降级、服务容错六、Dubbo 对比 OpenFeign 一、概述 Dubbo 是一款高性能、轻量级的开源Java RPC框架&#xff0c;它提供了三大核心能力&#…

总结Rabbitmq的六种模式

RabbitMQ六种工作模式 RabbitMQ是由erlang语言开发&#xff0c;基于AMQP&#xff08;Advanced Message Queue 高级消息队列协议&#xff09;协议实现的消息队列&#xff0c;它是一种应用程序之间的通信方法&#xff0c;消息队列在分布式系统开发中应用非常广泛。 RabbitMQ有六…