《Essential C++》之(面向过程泛型编程)
目录
🌼面向过程的编程风格 -- 第2章
🍈2.2
🍈2.4
🍈2.5
🍈2.6
🌼泛型编程风格 -- 第3章
🍍3.1
🍍3.4
前言
要求
完整代码
输入输出
🌼面向过程的编程风格 -- 第2章
🍈2.2
要求
Pentagonal 数列的求值公式 P(n) = n(3n - 1) / 2,借此产生1,5,12,22,35等元素值。试定义一个函数,利用上述公式,将产生的元素放到用户传入的 vector 中,元素个数由用户指定。请检查元素个数的有效性(太大可能引发 overflow 问题)。接下来编写第二个函数,能将给定的 vector 的所有元素一一打印出来。此函数的第二参数接受一个字符串,表示存放在 vector 内的数列的类型。最后再写一个 main,测试上述两个函数。
代码
#include<iostream>
#include<string>
#include<vector>
using namespace std;bool calc_elements(vector<int> &vec, int pos); // 计算并存储
void display_elems(vector<int> &vec,const string &title, ostream &os=cout); // 显示元素序列int main()
{vector<int> pent; // 存储元素序列const string title("Pentagonal Numeric Series"); // 定义一个字符串if (calc_elements(pent, 0)) // 计算并存储位置0的元素display_elems(pent, title); // 打印元素序列if (calc_elements(pent, 8))display_elems(pent, title);if (calc_elements(pent, 14))display_elems(pent, title);if (calc_elements(pent, 138))display_elems(pent, title);
}bool calc_elements(vector<int> &vec, int pos)
{// 检查元素个数有效性, 防止 overflowif (pos <= 0 || pos > 64) {cerr << "sorry. Invalid position: "<<pos<<endl;return false;}for (int ix = vec.size() + 1; ix <= pos; ++ix)vec.push_back( (ix*(3*ix-1)) / 2 ); // 插入元素return true;
}void display_elems(vector<int> &vec,const string &title, ostream &os)
{os << '\n' << title << "\n\t";for (int ix = 0; ix < vec.size(); ++ix)os << vec[ix]<<' ';os << endl;
}
输出
0和138都是非法输入
sorry. Invalid position: 0Pentagonal Numeric Series1 5 12 22 35 51 70 92Pentagonal Numeric Series1 5 12 22 35 51 70 92 117 145 176 210 247 287
sorry. Invalid position: 138Process returned 0 (0x0) execution time : 0.029 s
Press any key to continue.
🍈2.4
要求
写一个函数,以静态局部(local static)的vector储存 Pentagonal 数列元素。
此函数返回一个 const 指针,指向该 vector。
如果 vector 的大小小于指定的元素个数,就扩充 vector 的大小。
接下来再实现第二个函数,接受一个位置值,返回该位置上的元素。
最后,编写 main() 函数测试这些函数。
解释
(1)
// 第18行 return &_elems;
在函数
pentagonal_series
中,返回_elems
的地址(即指针)是为了避免将整个_elems
向量复制一次。通过返回指针,可以避免内存的额外开销,同时保证返回的是对同一个_elems
向量的引用。因为
_elems
是一个静态向量(static vector),它在函数第一次调用时被初始化,并且在后续的调用中保持着其状态。如果不使用指针返回_elems
,而是直接返回_elems
本身,那么每次函数调用时都会复制一份_elems
向量,这样会产生额外的开销和内存消耗。因此,通过返回指向
_elems
向量的指针,可以有效地避免不必要的复制操作和内存开销。
代码
#include<vector>
#include<iostream> // 输入输出流
using namespace std; // 标准命名空间// 检查输入是否有效
inline bool check_validity(int pos)
{return (pos <= 0 || pos > 64) ? false : true;
}// 生成和返回数列
const vector<int>* pentagonal_series(int pos)
{static vector<int> _elems; // 数列的静态向量if (check_validity(pos) && (pos > _elems.size())) // 该位置未计算for (int ix = _elems.size() + 1; ix <= pos; ++ix)_elems.push_back( ix * (3*ix-1) / 2);return &_elems; // 返回数列的指针
}// 获取指定位置的值
bool pentagonal_elem(int pos, int &elem)
{if (!check_validity(pos)) { // 无效输入cout<<"Sorry. Invalid position: "<<pos<<endl;elem = 0; // 元素置0return false;}const vector<int> *pent = pentagonal_series(pos); // 获取数列的指针elem = (*pent)[pos - 1]; // 指定位置元素值return true;
}int main()
{int elem;if (pentagonal_elem(8, elem)) // 计算并输出位置 8 的值cout<<"element 8 is "<<elem<<'\n';if (pentagonal_elem(88, elem))cout<<"element 88 is "<<elem<<'\n';if (pentagonal_elem(12, elem))cout<<"element 12 is "<<elem<<'\n';if (pentagonal_elem(64, elem))cout<<"element 64 is "<<elem<<'\n';
}
输出
element 8 is 92
Sorry. Invalid position: 88
element 12 is 210
element 64 is 6112
🍈2.5
2.6会用模板再实现一次
要求
实现一个重载的 max() 函数,接受以下参数:
(a) 两个整数
(b) 两个浮点数
(c) 两个字符串
- - - -
(d) 一个整数vector
(e) 一个浮点数vector
(f) 一个字符串vector
- - - -
(g) 一个整数数组 和 一个表示数组大小的整数值
(h) 一个浮点数数组 和 数组大小的整数值
(i) 一个字符串数组 和 数组大小的值
解释
(1)
inline string max(const string& t1, const string& t2)
a. 常量引用
const string&
。这是因为字符串类型string
的对象通常比较大,如果不使用引用传递的话,每次传递字符串时都会进行一次拷贝操作,这样会增加额外的开销和内存消耗.b. 使用常量引用作为函数参数,可以避免进行不必要的拷贝操作。常量引用允许我们在函数中以只读方式访问传递进来的字符串对象,而无需复制整个对象
(2)
这些函数被声明为
inline
,以允许编译器将其插入到程序中的调用点,从而提高性能
代码
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>using namespace std;inline int max(int t1, int t2){ return t1 > t2 ? t1 : t2; }inline float max(float t1, float t2){ return t1 > t2 ? t1 : t2; }// 常量引用
inline string max(const string& t1, const string& t2){ return t1 > t2 ? t1 : t2; }// -------------------------------------// 常量引用...
inline int max(const vector<int> &vec){ return *max_element(vec.begin(), vec.end()); }inline float max(const vector<float> &vec){ return *max_element(vec.begin(), vec.end()); }inline string max(const vector<string> &vec){ return *max_element(vec.begin(), vec.end()); }// -------------------------------------inline int max(const int *parray, int Size){ return *max_element(parray, parray + Size); }inline float max(const float *parray, int Size){ return *max_element(parray, parray + Size); }inline string max(const string *parray, int Size){ return *max_element(parray, parray + Size); }int main()
{string sarray[] = {"we", "were", "her", "pride", "of", "ten"};vector<string> svec(sarray, sarray + 6);int iarray[] = {12,70,2,169,1,5,29};vector<int> ivec(iarray, iarray + 7);float farray[] = {2.5, 24.8, 18.7, 4.1, 23.9};vector<float> fvec(farray, farray + 5);int imax = max( max(ivec), max(iarray, 7) );float fmax = max( max(fvec), max( farray, 5) );string smax = max ( max(svec), max(sarray, 6) );cout << "imax should be 169 -- found: "<< imax << '\n'<< "fmax should be 24.8 -- found: "<< fmax << '\n'<< "smax should be were -- found: "<< smax << '\n';return 0;
}
输出
imax should be 169 -- found: 169
fmax should be 24.8 -- found: 24.8
smax should be were -- found: were
🍈2.6
要求
以 template 重新完成练习 2.5,并对 main() 函数适度修改。
用一个 template max() 函数取代 9 个 non-template max() 函数。
main() 不需要任何修改。
解释
(1)如果函数名还是 max,会报错
(2)error: call of overloaded 'max(int, int)' is ambiguous
(3)二义性错误的原因是使用了自定义的
max
函数与<algorithm>
标准库中的std::max
函数冲突(4)这里将上个代码中的 max 改为 Max 即可
代码
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>using namespace std;template <typename Type>
inline Type Max(Type t1, Type t2){ return t1 > t2 ? t1 : t2; };template <typename elemType>
inline elemType Max( const vector<elemType> &vec){ return *max_element( vec.begin(), vec.end() ); }template <typename arrayType>
inline arrayType Max( const arrayType *parray, int Size){ return *max_element( parray, parray + Size ); }int main()
{string sarray[] = {"we", "were", "her", "pride", "of", "ten"};vector<string> svec(sarray, sarray + 6);int iarray[] = {12,70,2,169,1,5,29};vector<int> ivec(iarray, iarray + 7);float farray[] = {2.5, 24.8, 18.7, 4.1, 23.9};vector<float> fvec(farray, farray + 5);int imax = Max( Max(ivec), Max(iarray, 7) );float fmax = Max( Max(fvec), Max( farray, 5) );string smax = Max ( Max(svec), Max(sarray, 6) );cout << "imax should be 169 -- found: "<< imax << '\n'<< "fmax should be 24.8 -- found: "<< fmax << '\n'<< "smax should be were -- found: "<< smax << '\n';return 0;
}
输出
imax should be 169 -- found: 169
fmax should be 24.8 -- found: 24.8
smax should be were -- found: were
🌼泛型编程风格 -- 第3章
🍍3.1
要求
写一个读取文本文件的程序,将文件中的每个 key 存入map
再定义一个由 “排除字眼” 组成的 set,其中包含 a, an, or , the, but 之类的 Key
将某个 key 放入 map 前,先确定该 key 不在 “排除字集” 中
一旦文本读取完毕,显示一份 key 清单,并显示每个 key 出现次数
还可加以扩展,显示 key 前,允许用户查询某个 Key 是否出现在文本文件中
解释
(1)const set<string>& 为啥后面加个&
答:
在C++中,函数可以使用引用参数(Reference Parameter)。在函数声明中,在参数类型后面加上&符号就表示该参数是一个引用类型的参数。
const set<string>& exclude_set
这里的
exclude_set
是一个常量引用,它指向一个set<string>
对象。使用引用参数的好处是避免了函数调用时进行大量的拷贝操作,提高了程序的性能和效率。通过使用引用参数,函数可以直接访问和修改传递给它的实际对象,而无需创建对象的副本。另外,在这个示例代码中,将
exclude_set
声明为常量引用的原因是函数initialize_exclusion_set
只需要读取exclude_set
,而不会修改它的内容。通过将其声明为常量引用,可以确保函数内部不会意外地修改exclude_set
(2)
ifstream ifile("C:\\Users\\1\\Desktop\\C++\\column.txt"); ofstream ofile("C:\\Users\\1\\Desktop\\C++\\column.map");
答:
定义了两个文件流ifstream和ofstream,其中ifile打开了名为"C:\My Documents\column.txt"的文本文件,而ofile则打开了名为"C:\My Documents\column.map"的二进制文件。可以通过这些文件流来读取或写入文件中的内容
(3)
cerr << "Unable to open file -- bailing out!\n";
答:
a. cerr
是C++标准库中的一个输出流对象,它代表了标准错误流(standard error stream)。与cout
用于标准输出不同,cerr
主要用于将错误消息输出到终端或其他错误日志文件中。b.
<<
是C++中的流插入运算符,用于将字符串或其他数据插入到输出流中c.
cerr
,可以将错误信息输出到标准错误流中,而不是标准输出流cout
中。这样做有助于区分程序的正常输出和错误信息,方便调试和错误处理
(4)
map<string, int>::const_iterator it;
答:
声明了一个名为
it
的常量迭代器(iterator),用于遍历map<string, int>
容器中的元素迭代器:
迭代器将容器和算法联系起来。
在 C++ 标准库中,很多算法函数(如排序、查找、遍历等)都接受迭代器作为参数。这些算法函数不依赖于具体的容器类型,而是通过迭代器来遍历和处理容器中的元素,从而实现对容器的各种操作。
column.txt
MooCat is a long-haired white kitten with large
black patches Like a cow looks only he is a kitty
poor kitty Alice says cradling MooCat in her arms
pretending he is not struggling to break free
代码
#include<map> // 包含map库,用于使用映射容器
#include<set> // 包含set库,用于使用集合容器
#include<string> // 包含string库,用于使用字符串
#include<iostream> // 包含iostream库,用于输入输出操作
#include<fstream> // 包含fstream库,用于文件操作
using namespace std;void initialize_exclusion_set(set<string>&); // 初始化排除词集合
void process_file(map<string, int>&, const set<string>&, ifstream&); // 处理文件,统计单词出现次数
void user_query(const map<string, int>&); // 用户查询,查找指定单词的出现次数
void display_word_count(const map<string, int>&, ofstream&); // 显示单词及其出现次数int main()
{ifstream ifile("C:\\Users\\1\\Desktop\\C++\\column.txt"); // 打开输入文件流(读取文件)ofstream ofile("C:\\Users\\1\\Desktop\\C++\\column.map"); // 打开输出文件流(写入文件)if (!ifile || !ofile) {cerr << "Unable to open file -- bailing out!\n"; // 若打开文件失败输出错误信息并退出程序return -1;}set<string> exclude_set; // 定义排除词集合initialize_exclusion_set(exclude_set); // 初始化排除词集合map<string, int> word_count; // 定义单词计数映射容器process_file(word_count, exclude_set, ifile); // 处理文件,统计单词出现次数user_query(word_count); // 用户查询,查找指定单词的出现次数display_word_count(word_count, ofile); // 显示单词及其出现次数return 0;
}void initialize_exclusion_set(set<string>& exs) {static string _excluded_words[25] = {"the", "and", "but", "that", "then", "are", "been","can", "a", "could", "did", "for", "of","had", "have", "him", "his", "her", "its", "is","were", "which", "when", "with", "would"};exs.insert(_excluded_words, _excluded_words + 25); // 将排除词插入排除词集合中
}void process_file(map<string, int>& word_count,const set<string>& exclude_set, ifstream& ifile)
{string word;while (ifile >> word) {if (exclude_set.count(word))continue; // 若单词在排除词集合中,则跳过该单词继续下一次循环word_count[word]++; // 统计单词出现次数}
}void user_query(const map<string, int>& word_map)
{string search_word;cout << "Please enter a word to search: q to quit ";cin >> search_word;while (search_word.size() && search_word != "q") {map<string, int>::const_iterator it;if ((it = word_map.find(search_word)) != word_map.end())cout << "Found! " << it->first<< " occurs " << it->second<< " times.\n"; // 输出找到的单词及其出现次数else cout << search_word<< " was not found in text.\n"; // 输出未找到的单词信息cout << "\nAnother search? (q to quit) ";cin >> search_word;}
}void display_word_count(const map<string, int>& word_map, ofstream& os)
{map<string, int>::const_iteratoriter = word_map.begin(),end_it = word_map.end();while (iter != end_it) {os << iter->first << " ( "<< iter->second << " ) " << endl; // 输出单词及其出现次数到输出文件流++iter;}os << endl;
}
输出
Please enter a word to search: q to quit Alice
Found! Alice occurs 1 times.Another search? (q to quit) MooCat
Found! MooCat occurs 2 times.Another search? (q to quit) a
a was not found in text.Another search? (q to quit) q
🍍3.4
前言
(1) 关于back_inserter():back_inserter的使用-CSDN博客
(2)关于 partition()
std::partition - cppreference.com
c++11:std::partition-CSDN博客
(3)关于 copy():cplusplus.com/reference/algorithm/copy/
(4)关于 eos
eos
是一个标识迭代器,它表示输入数据的结束位置。在这段代码中,istream_iterator<int> eos;
声明了一个名为eos
的istream_iterator
对象,用于指示输入数据的结束。通过使用
copy(in, eos, back_inserter(input));
将输入流in
中的数据复制到整数型向量input
中。copy
函数会从in
开始读取数据,直到遇到eos
,即输入数据的结束位置。因此,
eos
在这里起到了标记输入数据结束位置的作用,它是一个特殊的迭代器,不指向实际的数据,只是表示输入结束的标志
要求
编写一个程序,利用 istream_iterator 从标准输入设备读取一连串整数。
利用 ostream_iterator 将其中的奇数写至某个文件,每个数值皆以空格分隔。
再利用 ostream_iterator 将偶数写到另一个文件,每个数值单独放在一行中。
首先定义2个 istream_iterator,用来从标准输入设备读入一串整数。其中一个绑定(bind)至 cin,另一个表示文件结束 (end-of-file)
istream_iterator<int> in( cin ), eos;
接下来,定义一个 vector,用来存储读入的元素:
vector< int > input;
以下使用泛型算法 copy() 进行读取操作:
#include <iterator>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;int main()
{vector< int > input;istream_iterator<int> in( cin ), eos;copy( in, eos, back_inserter( input ));// ...
}
在此,vector 是必要的,因为 copy() 会采用 assignment 运算符来复制每个元素。由于 input vector 是空的,第一个元素赋值操作就会导致溢出(overfolw)错误。使用 back_iterator() 可以避免 assignment 运算符,改以 push_back() 函数来插入函数。
下面以泛型算法 partition() 来区分奇偶数。当然还得配合 function object even_elem() 的使用,后者在传入值为偶数时会返回 true
class even_elem {
public:bool operator() ( int elem ){ return elem % 2 ? false : true; }
};vector<int>::iterator division = partition( input.begin(), input.end(), even_elem() );
还需要 2 个 ostream_iterator:一个用于偶数文件,一个用于奇数文件。
首先,以 ofstream class 打开两个输出文件:
#include<fstream>
ofstream even_file( "C:\\Users\\1\\Desktop\\C++\\even_file" ),odd_file( "C:\\Users\\1\\Desktop\\C++\\odd_file" );if ( !even_file || !odd_file) {cerr << "arghh! unable to open the output files. bailing out!";return -1;
}
再将这 2 个 ostream_iterator 绑定至相应的 ofstream 对象上。第 2 个参数代表每个元素输出时的分隔符。
ostream_iterator<int> even_iter( even_file, "\n" ),odd_iter( odd_file, " ");
最后,再以泛型算法 copy(),将已被分开的奇偶元素分别输出至不同文件:
copy( input.begin(), division, even_iter );
copy( division, input.end(), odd_iter );
完整代码
#include <iterator> // 包含迭代器相关的头文件
#include <vector> // 包含向量容器的头文件
#include <iostream> // 包含输入输出流的头文件
#include <algorithm> // 包含标准算法的头文件
#include <fstream> // 包含文件流的头文件
using namespace std; // 使用标准命名空间class even_elem { // 定义一个名为even_elem的类
public:bool operator()(int elem) // 重载()运算符,用于判断是否为偶数{return elem % 2 ? false : true; // 奇数返回 false}
};int main()
{vector<int> input; // 创建一个整型向量input,用于存储输入的数据istream_iterator<int> in(cin), eos; // 创建一个istream_iterator对象in,用于从cin读取数据copy(in, eos, back_inserter(input)); // 将输入的数据复制到input向量中// 使用partition函数将input向量中的元素按照even_elem对象进行分割,并返回分割点的迭代器vector<int>::iterator division = partition(input.begin(), input.end(), even_elem()); ofstream even_file("C:\\Users\\1\\Desktop\\C++\\even_file"), // 打开一个名为even_file的输出文件流odd_file("C:\\Users\\1\\Desktop\\C++\\odd_file"); // 打开一个名为odd_file的输出文件流if (!even_file || !odd_file) { // 检查是否成功打开了输出文件流,如果失败则输出错误信息并返回-1cerr << "arghh! unable to open the output files. bailing out!";return -1;}ostream_iterator<int> even_iter(even_file, "\n"), // 创建一个ostream_iterator对象even_iter,用于向even_file写入数据,并以换行符分隔odd_iter(odd_file, " "); // 创建一个ostream_iterator对象odd_iter,用于向odd_file写入数据,并以空格分隔copy(input.begin(), division, even_iter); // 将input向量中的偶数部分复制到even_iter指定的输出流中copy(division, input.end(), odd_iter); // 将input向量中的奇数部分复制到odd_iter指定的输出流中
}
输入输出
然后到创建好的文件查看就行
2 4 5 3 9 5 2 6 8 1 8 4 5 7 3 520 1314^Z
相关文章:
《Essential C++》之(面向过程泛型编程)
目录 🌼面向过程的编程风格 -- 第2章 🍈2.2 🍈2.4 🍈2.5 🍈2.6 🌼泛型编程风格 -- 第3章 🍍3.1 🍍3.4 前言 要求 完整代码 输入输出 🌼面向过程的编程风…...

机器学习笔记:adaBoost
1 介绍 AdaBoost(Adaptive Boosting)是一种集成学习方法,它的目标是将多个弱分类器组合成一个强分类器 通过反复修改训练数据的权重,使得之前分类错误的样本在后续的分类器中得到更多的关注每一轮中,都会增加一个新的…...

Anchor DETR
Anchor DETR(AAAI 2022) 改进: 提出了基于anchor的对象查询提出Attention变体-RCDA 在以前DETR中,目标的查询是一组可学习的embedding。然而,每个可学习的embedding都没有明确的意义 (因为是随机初始化的)ÿ…...

适合在家做的副业 整理5个,有电脑就行
今天,我们不说别的,整理5个适合个人在家单干的副业。需要电脑,如果你没电脑就不用看了,最后两个,我们也在做,你可以看到最后了解。这些副业,大家多去实践操作,前期,每月三…...
Android WebSocket
WS Android WebSocket 资源 名字资源AAR下载GitHub查看Gitee查看 Maven 1.build.grade allprojects {repositories {...maven { url https://jitpack.io }} }2./app/build.grade dependencies {implementation com.github.RelinRan:WS:2022.2023.9.23.1 }初始化 配置权…...
Android 按键流程
一、驱动层流程 主要流程涉及以下文件 kernel/msm-4.19/drivers/input/keyboard/gpio_keys.c kernel/msm-4.19/drivers/input/input.c kernel/msm-4.19/drivers/input/evdev.c kernel/msm-4.19/drivers/input/input-compat.c 有按键动作时,根据 dtsi 中配置 c…...

C语言——运算符
C用运算符表示算术运算。 C没有指数运算符,不过,C的标准数学库提供了一个pow()函数用于指数运算。 基本运算符 赋值运算符: 变量名变量值 从右到左 左值和变量名的区别: 变量名是一个标识符的名称,左值是一个可变…...

MySQL数据库入门到精通8--进阶篇( MySQL管理)
7. MySQL管理 7.1 系统数据库 Mysql数据库安装完成后,自带了一下四个数据库,具体作用如下: 7.2 常用工具 7.2.1 mysql 该mysql不是指mysql服务,而是指mysql的客户端工具。 语法 : mysql [options] [database] 选…...

硬件基本功--MOS管
一、上下拉电阻Rgs的作用 Rgs:经验值,一般取10K左右。 1. 上电时给MOS管的栅极一个确定的电平,防止上电时GPIO为高阻态时,MOS管的栅极电平不确定,从而受到干扰。 2. 断电时,如果MOS管是导通的状态ÿ…...

xdebug3开启profile和trace
【xdebug开启profiler】 https://xdebug.org/docs/profiler http://www.xdebug.org.cn/docs/profiler 1、php.ini添加下面配置然后重启php容器: xdebug.modeprofile ;这个目录保存profile和trace文件 xdebug.output_dir /var/tmp/xdebugPHP日志提示报错:…...

EfficientFormer:高效低延迟的Vision Transformers
我们都知道Transformers相对于CNN的架构效率并不高,这导致在一些边缘设备进行推理时延迟会很高,所以这次介绍的论文EfficientFormer号称在准确率不降低的同时可以达到MobileNet的推理速度。 Transformers能否在获得高性能的同时,跑得和Mobile…...

【咕咕送书第二期】| 计算机网络对于考研的重要性?
🎬 鸽芷咕:个人主页 🔥 个人专栏:《粉丝福利》 《C语言进阶篇》 ⛺️生活的理想,就是为了理想的生活! 文章目录 📋 前言什么是计算机网络?01 为什么计算机专业要学计算机网络02 计算机网络对考研的重要性 …...
【力扣】58. 最后一个单词的长度
题目描述 给你一个字符串 s,由若干单词组成,单词前后用一些空格字符隔开。返回字符串中 最后一个 单词的长度。 单词 是指仅由字母组成、不包含任何空格字符的最大子字符串。 示例 1: 输入:s “Hello World” 输出:…...

Java编程的精髓:深入理解JVM和性能优化
文章目录 Java虚拟机(JVM)的核心概念1. 类加载器(Class Loader)2. 内存区域3. 垃圾回收(Garbage Collection)4. 类型转换和多态 JVM性能调优1. JVM参数调整2. 内存管理3. 多线程优化4. 使用性能分析工具5. …...

易云维®智慧工厂数字化管理平台助推工业制造企业数字化转型新动能
近年来,我国正在积极推进工业制造企业数字化转型,工业制造企业数字化转型迎来了密集的利好政策,近期,国家工信部又出台系列政策,实施工业制造企业数字化促进工程,推动工业制造企业更快更好地拥抱数字经济。…...
0.基本概念——数据结构学习
数据结构是一门研究非数值计算的程序设计问题中的操作对象,以及它们之间的关系和操作等相关问题的学科。 数据:描述客观事物的符号,是计算机可以操作的对象,是能被计算机识别,并输出给计算机处理的符号集合。数据元素…...

Redis可视化工具-Another Redis Desktop Manager 安装
Another Redis DeskTop Manager 是 Redis 可视化管理工具,体积小,完全免费。最重要的是稳定,而且操作简单、方便。 目录 一、下载安装 下载 安装 二、简单使用 连接 新增key 三、springboot整合redis 前期准备 一、下载安装 下载 下载…...

ETLCloud工具让美团数据管理更简单
美团为第三方开发者和商家提供了一系列开放的API接口和工具,使其可以与美团的业务进行对接和集成,从而获得更多的业务机会和增长空间。 通过美团开放平台,第三方开发者和商家可以实现以下功能: 开放接口:美团开放平台…...

ctfshow 命令执行 (29-39)
学习参考的 https://www.cnblogs.com/NPFS/p/13279815.html 说的很全面 web29 命令执行,需要严格的过滤 源码 error_reporting(0); if(isset($_GET[c])){$c $_GET[c];if(!preg_match("/flag/i", $c)){eval($c);}}else{highlight_file(__FILE__); } …...

如何玩转CSDN AI工具集
前言 人工智能生成内容(AIGC)是当下最具有前景的技术领域之一。AI能够以惊人的速度和准确度生成各种类型的内容,完成文章翻译、代码生成、AI对话、插图创作等工作,带来了许多令人兴奋的机遇。 本文将介绍CSDN AI工具集的基本使用…...

MPNet:旋转机械轻量化故障诊断模型详解python代码复现
目录 一、问题背景与挑战 二、MPNet核心架构 2.1 多分支特征融合模块(MBFM) 2.2 残差注意力金字塔模块(RAPM) 2.2.1 空间金字塔注意力(SPA) 2.2.2 金字塔残差块(PRBlock) 2.3 分类器设计 三、关键技术突破 3.1 多尺度特征融合 3.2 轻量化设计策略 3.3 抗噪声…...

RocketMQ延迟消息机制
两种延迟消息 RocketMQ中提供了两种延迟消息机制 指定固定的延迟级别 通过在Message中设定一个MessageDelayLevel参数,对应18个预设的延迟级别指定时间点的延迟级别 通过在Message中设定一个DeliverTimeMS指定一个Long类型表示的具体时间点。到了时间点后…...
mongodb源码分析session执行handleRequest命令find过程
mongo/transport/service_state_machine.cpp已经分析startSession创建ASIOSession过程,并且验证connection是否超过限制ASIOSession和connection是循环接受客户端命令,把数据流转换成Message,状态转变流程是:State::Created 》 St…...
postgresql|数据库|只读用户的创建和删除(备忘)
CREATE USER read_only WITH PASSWORD 密码 -- 连接到xxx数据库 \c xxx -- 授予对xxx数据库的只读权限 GRANT CONNECT ON DATABASE xxx TO read_only; GRANT USAGE ON SCHEMA public TO read_only; GRANT SELECT ON ALL TABLES IN SCHEMA public TO read_only; GRANT EXECUTE O…...
【Go】3、Go语言进阶与依赖管理
前言 本系列文章参考自稀土掘金上的 【字节内部课】公开课,做自我学习总结整理。 Go语言并发编程 Go语言原生支持并发编程,它的核心机制是 Goroutine 协程、Channel 通道,并基于CSP(Communicating Sequential Processes࿰…...

【7色560页】职场可视化逻辑图高级数据分析PPT模版
7种色调职场工作汇报PPT,橙蓝、黑红、红蓝、蓝橙灰、浅蓝、浅绿、深蓝七种色调模版 【7色560页】职场可视化逻辑图高级数据分析PPT模版:职场可视化逻辑图分析PPT模版https://pan.quark.cn/s/78aeabbd92d1...

NXP S32K146 T-Box 携手 SD NAND(贴片式TF卡):驱动汽车智能革新的黄金组合
在汽车智能化的汹涌浪潮中,车辆不再仅仅是传统的交通工具,而是逐步演变为高度智能的移动终端。这一转变的核心支撑,来自于车内关键技术的深度融合与协同创新。车载远程信息处理盒(T-Box)方案:NXP S32K146 与…...

Python基于历史模拟方法实现投资组合风险管理的VaR与ES模型项目实战
说明:这是一个机器学习实战项目(附带数据代码文档),如需数据代码文档可以直接到文章最后关注获取。 1.项目背景 在金融市场日益复杂和波动加剧的背景下,风险管理成为金融机构和个人投资者关注的核心议题之一。VaR&…...
Leetcode33( 搜索旋转排序数组)
题目表述 整数数组 nums 按升序排列,数组中的值 互不相同 。 在传递给函数之前,nums 在预先未知的某个下标 k(0 < k < nums.length)上进行了 旋转,使数组变为 [nums[k], nums[k1], …, nums[n-1], nums[0], nu…...
es6+和css3新增的特性有哪些
一:ECMAScript 新特性(ES6) ES6 (2015) - 革命性更新 1,记住的方法,从一个方法里面用到了哪些技术 1,let /const块级作用域声明2,**默认参数**:函数参数可以设置默认值。3&#x…...