当前位置: 首页 > news >正文

C++提高编程——STL:string容器、vector容器

本专栏记录C++学习过程包括C++基础以及数据结构和算法,其中第一部分计划时间一个月,主要跟着黑马视频教程,学习路线如下,不定时更新,欢迎关注
当前章节处于:
---------第1阶段-C++基础入门
---------第2阶段实战-通讯录管理系统,
---------第3阶段-C++核心编程,
---------第4阶段实战-基于多态的企业职工系统
=====>第5阶段-C++提高编程
---------第6阶段实战-基于STL泛化编程的演讲比赛
---------第7阶段-C++实战项目机房预约管理系统

文章目录

  • 一、STL初识
  • 二、 string 容器
    • 2.1 string构造函数
    • 2.2 string赋值操作
    • 2.3 string字符串拼接
    • 2.4 string查找和替换
    • 2.5 string字符串比较
    • 2.6 string字符存取
    • 2.7 string插入和删除
    • 2.8 string子串
  • 三、Vector容器
    • 3.1 基本概念
    • 3.2 vector构造函数
    • 3.3 vector赋值操作
    • 3.4 vector容量和大小
    • 3.5 vector插入和删除
    • 3.6 vector数据存取
    • 3.7 vector互换容器
    • 3.8 vector预留空间

一、STL初识

长久以来,软件界一致希望简历一种可重复利用的东西,C++面向对象和泛型编程的思想,目的就是复用性的提升,大多情况下数据结构和算法都未能有一套标准,导致大量重复性工作的产生,为了建立数据结构和算法的一套标准,诞生了STL

STL (Standard Template Library,标准模板库)
STL从广义上分为

  1. 容器(container)

    • 序列式容器:强调值的排序,序列式容器中的每个元素均有固定的位置
    • 关联式容器:二叉树结构,各元素之间没有严格的物理上的顺序关系
  2. 算法(algorithm)

    • 质变算法:运算过程中会更改区间内的元素内容,比如拷贝、替换、删除等
    • 非质变算法:运算过程中不会更改区间内的元素内容,比如查找、计数、遍历、寻找极值等
  3. 迭代器(iterator)

在这里插入图片描述

容器和算法之间通过迭代器进行无缝连接,STL几乎所有代码都采用了模板类或者模板函数。
stl大体分为六大组件,分别是:容器、算法、迭代器、仿函数、适配器(配接器)、空间配置器。

  1. 容器:各种数据结构,如vector、list、deque、set、map等用来存放数据
  2. 算法:各种常用的算法,sort、find、copy、for_each等
  3. 迭代器:扮演了容器和算法之间的胶合剂
  4. 仿函数“行为类似函数,可作为算法的某种策略
  5. 适配器:一种用来修饰容器或者仿函数或者迭代器接口的东西
  6. 空间配置器:负责空间的配置和管理。
#include <iostream>
using namespace std;
#include <vector>
#include <algorithm>
void myprint(int num) {cout << num << endl;
}
int main() {// 创建容器vector<int> v;// 向容器中添加元素v.push_back(10);v.push_back(20);v.push_back(30);v.push_back(40);// 遍历容器// 方法一for (vector<int>::iterator it = v.begin(); it != v.end(); it++) {cout << *it << endl;}// 方法二for_each(v.begin(), v.end(), myprint);system("pause");return 0;}
10
20
30
40
10
20
30
40
请按任意键继续. . .

二、 string 容器

string 是C++风格的字符串,本质是一个类

string和char * 区别:

  • char * 是一个指针
  • string是一个类,类内部封装了char*,管理这个字符串,是一个char*型的容器。

特点:

string 类内部封装了很多成员方法

例如:查找find,拷贝copy,删除delete 替换replace,插入insert

string管理char*所分配的内存,不用担心复制越界和取值越界等,由类内部进行负责

2.1 string构造函数

构造函数原型:

  • string(); //创建一个空的字符串 例如: string str;
    string(const char* s); //使用字符串s初始化
  • string(const string& str); //使用一个string对象初始化另一个string对象
  • string(int n, char c); //使用n个字符c初始化
#include <iostream>
using namespace std;int main() {string s1; //创建空字符串,调用无参构造函数cout << "str1 = " << s1 << endl;const char* str = "hello world";string s2(str); //把c_string转换成了stringcout << "str2 = " << s2 << endl;string s3(s2); //调用拷贝构造函数cout << "str3 = " << s3 << endl;string s4(10, 'a');cout << "str3 = " << s3 << endl;system("pause");return 0;}
str1 =
str2 = hello world
str3 = hello world
str3 = hello world
请按任意键继续. . .

2.2 string赋值操作

给字符串赋值,赋值的函数原型:

  • string& operator=(const char* s); //char*类型字符串 赋值给当前的字符串
  • string& operator=(const string &s); //把字符串s赋给当前的字符串
  • string& operator=(char c); //字符赋值给当前的字符串
  • string& assign(const char *s); //把字符串s赋给当前的字符串
  • string& assign(const char *s, int n); //把字符串s的前n个字符赋给当前的字符串
  • string& assign(const string &s); //把字符串s赋给当前字符串
  • string& assign(int n, char c); //用n个字符c赋给当前字符串
#include <iostream>
using namespace std;int main() {string str1;str1 = "hello world";cout << "str1 = " << str1 << endl;string str2;str2 = str1;cout << "str2 = " << str2 << endl;string str3;str3 = 'a';cout << "str3 = " << str3 << endl;string str4;str4.assign("hello c++");cout << "str4 = " << str4 << endl;string str5;str5.assign("hello c++", 5);cout << "str5 = " << str5 << endl;string str6;str6.assign(str5);cout << "str6 = " << str6 << endl;string str7;str7.assign(5, 'x');cout << "str7 = " << str7 << endl;system("pause");return 0;}
str1 = hello world
str2 = hello world
str3 = a
str4 = hello c++
str5 = hello
str6 = hello
str7 = xxxxx
请按任意键继续. . .

2.3 string字符串拼接

函数原型:

  • string& operator+=(const char* str); //重载+=操作符
  • string& operator+=(const char c); //重载+=操作符
  • string& operator+=(const string& str); //重载+=操作符
  • string& append(const char *s); //把字符串s连接到当前字符串结尾
  • string& append(const char *s, int n); //把字符串s的前n个字符连接到当前字符串结尾
  • string& append(const string &s); //同operator+=(const string& str)
  • string& append(const string &s, int pos, int n);//字符串s中从pos开始的n个字符连接到字符串结尾
#include <iostream>
using namespace std;int main() {string str1 = "我";str1 += "爱玩游戏";cout << "str1 = " << str1 << endl;str1 += ':';cout << "str1 = " << str1 << endl;string str2 = "LOL DNF";str1 += str2;cout << "str1 = " << str1 << endl;string str3 = "I";str3.append(" love ");str3.append("game abcde", 4);//str3.append(str2);str3.append(str2, 4, 3); // 从下标4位置开始 ,截取3个字符,拼接到字符串末尾cout << "str3 = " << str3 << endl;system("pause");return 0;}
str1 = 我爱玩游戏
str1 = 我爱玩游戏:
str1 = 我爱玩游戏:LOL DNF
str3 = I love gameDNF
请按任意键继续. . .

2.4 string查找和替换

查找是找指定字符串是否存在,替换是替换掉指定字符串
函数原型:

  • int find(const string& str, int pos = 0) const; //查找str第一次出现位置,从pos开始查找
  • int find(const char* s, int pos = 0) const; //查找s第一次出现位置,从pos开始查找
  • int find(const char* s, int pos, int n) const; //从pos位置查找s的前n个字符第一次位置
  • int find(const char c, int pos = 0) const; //查找字符c第一次出现位置
  • int rfind(const string& str, int pos = npos) const; //查找str最后一次位置,从pos开始查找
  • int rfind(const char* s, int pos = npos) const; //查找s最后一次出现位置,从pos开始查找
  • int rfind(const char* s, int pos, int n) const; //从pos查找s的前n个字符最后一次位置
  • int rfind(const char c, int pos = 0) const; //查找字符c最后一次出现位置
  • string& replace(int pos, int n, const string& str); //替换从pos开始n个字符为字符串str
  • string& replace(int pos, int n,const char* s); //替换从pos开始的n个字符为字符串s
#include <iostream>
using namespace std;//查找和替换
void test01()
{//查找string str1 = "abcdefgde";int pos = str1.find("de");if (pos == -1){cout << "未找到" << endl;}else{cout << "pos = " << pos << endl;}pos = str1.rfind("de");cout << "pos = " << pos << endl;}void test02()
{//替换string str1 = "abcdefgde";str1.replace(1, 3, "1111");cout << "str1 = " << str1 << endl;
}int main() {test01();test02();system("pause");return 0;
}
pos = 3
pos = 7
str1 = a1111efgde
请按任意键继续. . .

总结:

  • find查找是从左往后,rfind从右往左
  • find找到字符串后返回查找的第一个字符位置,找不到返回-1
  • replace在替换时,要指定从哪个位置起,多少个字符,替换成什么样的字符串

2.5 string字符串比较

功能描述:

  • 字符串之间的比较

比较方式:

  • 字符串比较是按字符的ASCII码进行对比

= 返回 0

> 返回 1

< 返回 -1

函数原型:

  • int compare(const string &s) const; //与字符串s比较
  • int compare(const char *s) const; //与字符串s比较
#include <iostream>
using namespace std;
//字符串比较
void test01()
{string s1 = "hello";string s2 = "aello";int ret = s1.compare(s2);if (ret == 0) {cout << "s1 等于 s2" << endl;}else if (ret > 0){cout << "s1 大于 s2" << endl;}else{cout << "s1 小于 s2" << endl;}}int main() {test01();system("pause");return 0;
}
s1 大于 s2
请按任意键继续. . .

总结:字符串对比主要是用于比较两个字符串是否相等,判断谁大谁小的意义并不是很大

2.6 string字符存取

string中单个字符存取方式有两种

  • char& operator[](int n); //通过[]方式取字符
  • char& at(int n); //通过at方法获取字符
#include <iostream>
using namespace std;
void test01()
{string str = "hello world";for (int i = 0; i < str.size(); i++){cout << str[i] << " ";}cout << endl;for (int i = 0; i < str.size(); i++){cout << str.at(i) << " ";}cout << endl;//字符修改str[0] = 'x';str.at(1) = 'x';cout << str << endl;}int main() {test01();system("pause");return 0;
}
h e l l o   w o r l d
h e l l o   w o r l d
xxllo world
请按任意键继续. . .
在这里插入代码片

总结:string字符串中单个字符存取有两种方式,利用 [ ] 或 at

2.7 string插入和删除

功能描述:

  • 对string字符串进行插入和删除字符操作

函数原型:

  • string& insert(int pos, const char* s); //插入字符串
  • string& insert(int pos, const string& str); //插入字符串
  • string& insert(int pos, int n, char c); //在指定位置插入n个字符c
  • string& erase(int pos, int n = npos); //删除从Pos开始的n个字符
#include <iostream>
using namespace std;//字符串插入和删除
void test01()
{string str = "hello";str.insert(1, "111");cout << str << endl;str.erase(1, 3);  //从1号位置开始3个字符cout << str << endl;
}int main() {test01();system("pause");return 0;
}
h111ello
hello
请按任意键继续. . .

**总结:**插入和删除的起始下标都是从0开始

2.8 string子串

功能描述:

  • 从字符串中获取想要的子串

函数原型:

  • string substr(int pos = 0, int n = npos) const; //返回由pos开始的n个字符组成的字符串
#include <iostream>
using namespace std;//子串
void test01()
{string str = "abcdefg";string subStr = str.substr(1, 3);cout << "subStr = " << subStr << endl;string email = "hello@sina.com";int pos = email.find("@");string username = email.substr(0, pos);cout << "username: " << username << endl;}int main() {test01();system("pause");return 0;
}
subStr = bcd
username: hello
请按任意键继续. .

总结:灵活的运用求子串功能,可以在实际开发中获取有效的信息

三、Vector容器

3.1 基本概念

vector数据结构和数组非常相似,也称为单端数组,不同之处在于数组是静态空间,而vector可以动态扩展,动态扩展机制 并不是在原空间之后续接新空间,而是找更大的内存空间,然后将原数据拷贝新空间,释放原空间。vector容器的迭代器是支持随机访问的迭代器。

3.2 vector构造函数

功能描述:

  • 创建vector容器

函数原型:

  • vector<T> v; //采用模板实现类实现,默认构造函数
  • vector(v.begin(), v.end()); //将v[begin(), end())区间中的元素拷贝给本身。
  • vector(n, elem); //构造函数将n个elem拷贝给本身。
  • vector(const vector &vec); //拷贝构造函数。

示例:

#include <iostream>
using namespace std;
#include <vector>void printVector(vector<int>& v) {for (vector<int>::iterator it = v.begin(); it != v.end(); it++) {cout << *it << " ";}cout << endl;
}void test01()
{vector<int> v1; //无参构造for (int i = 0; i < 10; i++){v1.push_back(i);}printVector(v1);vector<int> v2(v1.begin(), v1.end());printVector(v2);vector<int> v3(10, 100);// 10个100printVector(v3);vector<int> v4(v3);printVector(v4);
}int main() {test01();system("pause");return 0;
}
0 1 2 3 4 5 6 7 8 9
0 1 2 3 4 5 6 7 8 9
100 100 100 100 100 100 100 100 100 100
100 100 100 100 100 100 100 100 100 100
请按任意键继续. . .

总结: vector的多种构造方式没有可比性,灵活使用即可

3.3 vector赋值操作

功能描述:

  • 给vector容器进行赋值

函数原型:

  • vector& operator=(const vector &vec);//重载等号操作符

  • assign(beg, end); //将[beg, end)区间中的数据拷贝赋值给本身。

  • assign(n, elem); //将n个elem拷贝赋值给本身。

示例:

#include <iostream>
using namespace std;#include <vector>void printVector(vector<int>& v) {for (vector<int>::iterator it = v.begin(); it != v.end(); it++) {cout << *it << " ";}cout << endl;
}//赋值操作
void test01()
{vector<int> v1; //无参构造for (int i = 0; i < 10; i++){v1.push_back(i);}printVector(v1);vector<int>v2;v2 = v1;printVector(v2);vector<int>v3;v3.assign(v1.begin(), v1.end());printVector(v3);vector<int>v4;v4.assign(10, 100);printVector(v4);
}int main() {test01();system("pause");return 0;
}
0 1 2 3 4 5 6 7 8 9
0 1 2 3 4 5 6 7 8 9
0 1 2 3 4 5 6 7 8 9
100 100 100 100 100 100 100 100 100 100
请按任意键继续. . .

总结: vector赋值方式比较简单,使用operator=,或者assign都可以

3.4 vector容量和大小

功能描述:

  • 对vector容器的容量和大小操作

函数原型:

  • empty(); //判断容器是否为空

  • capacity(); //容器的容量

  • size(); //返回容器中元素的个数

  • resize(int num); //重新指定容器的长度为num,若容器变长,则以默认值填充新位置。

    ​ //如果容器变短,则末尾超出容器长度的元素被删除。

  • resize(int num, elem); //重新指定容器的长度为num,若容器变长,则以elem值填充新位置。

    ​ //如果容器变短,则末尾超出容器长度的元素被删除

示例:

#include <iostream>
using namespace std;#include <vector>void printVector(vector<int>& v) {for (vector<int>::iterator it = v.begin(); it != v.end(); it++) {cout << *it << " ";}cout << endl;
}void test01()
{vector<int> v1;for (int i = 0; i < 10; i++){v1.push_back(i);}printVector(v1);if (v1.empty()){cout << "v1为空" << endl;}else{cout << "v1不为空" << endl;cout << "v1的容量 = " << v1.capacity() << endl;cout << "v1的大小 = " << v1.size() << endl;}//resize 重新指定大小 ,若指定的更大,默认用0填充新位置,可以利用重载版本替换默认填充v1.resize(15, 10);printVector(v1);//resize 重新指定大小 ,若指定的更小,超出部分元素被删除v1.resize(5);printVector(v1);
}int main() {test01();system("pause");return 0;
}
0 1 2 3 4 5 6 7 8 9
v1不为空
v1的容量 = 13
v1的大小 = 10
0 1 2 3 4 5 6 7 8 9 10 10 10 10 10
0 1 2 3 4
请按任意键继续. . .

总结:

  • 判断是否为空 — empty
  • 返回元素个数 — size
  • 返回容器容量 — capacity
  • 重新指定大小 — resize

3.5 vector插入和删除

功能描述:

  • 对vector容器进行插入、删除操作

函数原型:

  • push_back(ele); //尾部插入元素ele
  • pop_back(); //删除最后一个元素
  • insert(const_iterator pos, ele); //迭代器指向位置pos插入元素ele
  • insert(const_iterator pos, int count,ele);//迭代器指向位置pos插入count个元素ele
  • erase(const_iterator pos); //删除迭代器指向的元素
  • erase(const_iterator start, const_iterator end);//删除迭代器从start到end之间的元素
  • clear(); //删除容器中所有元素

示例:

#include <iostream>
using namespace std;#include <vector>void printVector(vector<int>& v) {for (vector<int>::iterator it = v.begin(); it != v.end(); it++) {cout << *it << " ";}cout << endl;
}//插入和删除
void test01()
{vector<int> v1;//尾插v1.push_back(10);v1.push_back(20);v1.push_back(30);v1.push_back(40);v1.push_back(50);printVector(v1);//尾删v1.pop_back();printVector(v1);//插入v1.insert(v1.begin(), 100);printVector(v1);v1.insert(v1.begin(), 2, 1000); // 插入两个1000printVector(v1);//删除v1.erase(v1.begin());printVector(v1);//清空v1.erase(v1.begin(), v1.end());v1.clear();printVector(v1);
}int main() {test01();system("pause");return 0;
}
10 20 30 40 50
10 20 30 40
100 10 20 30 40
1000 1000 100 10 20 30 40
1000 100 10 20 30 40请按任意键继续. . .

总结:

  • 尾插 — push_back
  • 尾删 — pop_back
  • 插入 — insert (位置迭代器)
  • 删除 — erase (位置迭代器)
  • 清空 — clear

3.6 vector数据存取

功能描述:

  • 对vector中的数据的存取操作

函数原型:

  • at(int idx); //返回索引idx所指的数据
  • operator[]; //返回索引idx所指的数据
  • front(); //返回容器中第一个数据元素
  • back(); //返回容器中最后一个数据元素

示例:

#include <iostream>
using namespace std;#include <vector>void test01()
{vector<int>v1;for (int i = 0; i < 10; i++){v1.push_back(i);}for (int i = 0; i < v1.size(); i++){cout << v1[i] << " ";}cout << endl;for (int i = 0; i < v1.size(); i++){cout << v1.at(i) << " ";}cout << endl;cout << "v1的第一个元素为: " << v1.front() << endl;cout << "v1的最后一个元素为: " << v1.back() << endl;
}int main() {test01();system("pause");return 0;
}
0 1 2 3 4 5 6 7 8 9
0 1 2 3 4 5 6 7 8 9
v1的第一个元素为: 0
v1的最后一个元素为: 9
请按任意键继续. . .

总结:

  • 除了用迭代器获取vector容器中元素,[ ]和at也可以
  • front返回容器第一个元素
  • back返回容器最后一个元素

3.7 vector互换容器

功能描述:

  • 实现两个容器内元素进行互换

函数原型:

  • swap(vec); // 将vec与本身的元素互换

示例:

#include <iostream>
using namespace std;#include <vector>void printVector(vector<int>& v) {for (vector<int>::iterator it = v.begin(); it != v.end(); it++) {cout << *it << " ";}cout << endl;
}void test01()
{vector<int>v1;for (int i = 0; i < 10; i++){v1.push_back(i);}printVector(v1);vector<int>v2;for (int i = 10; i > 0; i--){v2.push_back(i);}printVector(v2);//互换容器cout << "互换后" << endl;v1.swap(v2);printVector(v1);printVector(v2);
}void test02()
{vector<int> v;for (int i = 0; i < 100000; i++) {v.push_back(i);}cout << "v的容量为:" << v.capacity() << endl;cout << "v的大小为:" << v.size() << endl;v.resize(3);cout << "v的容量为:" << v.capacity() << endl;cout << "v的大小为:" << v.size() << endl;//收缩内存vector<int>(v).swap(v); //匿名对象,会根据v.size去创建一个匿名函数cout << "v的容量为:" << v.capacity() << endl;cout << "v的大小为:" << v.size() << endl;
}int main() {test01();test02();system("pause");return 0;
}
0 1 2 3 4 5 6 7 8 9
10 9 8 7 6 5 4 3 2 1
互换后
10 9 8 7 6 5 4 3 2 1
0 1 2 3 4 5 6 7 8 9
v的容量为:138255
v的大小为:100000
v的容量为:138255
v的大小为:3
v的容量为:3
v的大小为:3
请按任意键继续. . .

总结:swap可以使两个容器互换,可以达到实用的收缩内存效果

3.8 vector预留空间

功能描述:

  • 减少vector在动态扩展容量时的扩展次数

函数原型:

  • reserve(int len);//容器预留len个元素长度,预留位置不初始化,元素不可访问。

示例:

#include <iostream>
using namespace std;
#include <vector>void test01()
{vector<int> v;//预留空间v.reserve(100000);int num = 0;int* p = NULL;for (int i = 0; i < 100000; i++) {v.push_back(i);if (p != &v[0]) {p = &v[0];num++;}}cout << "num:" << num << endl;
}int main() {test01();system("pause");return 0;
}
num:1
请按任意键继续. . .

总结:如果数据量较大,可以一开始利用reserve预留空间

相关文章:

C++提高编程——STL:string容器、vector容器

本专栏记录C学习过程包括C基础以及数据结构和算法&#xff0c;其中第一部分计划时间一个月&#xff0c;主要跟着黑马视频教程&#xff0c;学习路线如下&#xff0c;不定时更新&#xff0c;欢迎关注。 当前章节处于&#xff1a; ---------第1阶段-C基础入门 ---------第2阶段实战…...

three.js从入门到精通系列教程004 - three.js透视相机(PerspectiveCamera)滚动浏览全景大图

<!DOCTYPE html> <html><head><meta charset"UTF-8"><title>three.js从入门到精通系列教程004 - three.js透视相机&#xff08;PerspectiveCamera&#xff09;滚动浏览全景大图</title><script src"js/three.js"&g…...

Gradle 笔记

Gradle依赖管理&#xff08;基于Kotlin DSL&#xff09; **注意&#xff1a;**如果不是工作原因或是编写安卓项目必须要用Gradle&#xff0c;建议学习Maven即可&#xff0c;Gradle的学习成本相比Maven高很多&#xff0c;而且学了有没有用还是另一回事&#xff0c;所以&#xff…...

flume案例

在构建数仓时&#xff0c;经常会用到flume接收日志数据&#xff0c;通常涉及到的组件为kafka&#xff0c;hdfs等。下面以一个flume接收指定topic数据&#xff0c;并存入hdfs的案例&#xff0c;大致了解下flume相关使用规则。 版本&#xff1a;1.9 Source Kafka Source就是一…...

信用评价研究MATLAB仿真代码

信用评价是各种店铺卖家分析买家信用行为的重要内容, 本文给出随机仿真代码模拟实际交易过程的信用评价. 主要研究内容有: (1)研究最大交易额和信用度的关系 (2)研究买家不评价率对信用度影响 (3)研究交易次数对信用度影响 MATLAB程序如下: 主程序main.m %% clc;close a…...

网络安全产品之认识防毒墙

在互联网发展的初期&#xff0c;网络结构相对简单&#xff0c;病毒通常利用操作系统和软件程序的漏洞发起攻击&#xff0c;厂商们针对这些漏洞发布补丁程序。然而&#xff0c;并不是所有终端都能及时更新这些补丁&#xff0c;随着网络安全威胁的不断升级和互联网的普及&#xf…...

android 防抖工具类,经纬度检查工具类

一&#xff1a;点击事件防抖工具类&#xff1a; public abstract class ThrottleClickListener implements View.OnClickListener {private long clickLastTimeKey 0;private final long thresholdMillis 500;//millisecondsOverridepublic void onClick(View v) {long curr…...

PgSQL - 17新特性 - 块级别增量备份

PgSQL - 17新特性 - 块级别增量备份 PgSQL可通过pg_basebackup进行全量备份。在构建复制关系时&#xff0c;创建备机时需要通过pg_basebackup全量拉取一个备份&#xff0c;形成一个mirror。但很多场景下&#xff0c;我们往往不需要进行全量备份/恢复&#xff0c;数据量特别大的…...

Vue3setup()的非语法糖和语法糖的用法

1、setup()的语法糖的用法 script标签上写setup属性&#xff0c;不需要export default {} setup() 都可以省 创建每个属性或方法时也不需要return 导入某个组件时也不需要注册 <script setup > // script标签上写setup属性&#xff0c;不需要export default {} set…...

HTTP状态信息

1xx: 信息 消息:描述:100 Continue服务器仅接收到部分请求&#xff0c;但是一旦服务器并没有拒绝该请求&#xff0c;客户端应该继续发送其余的请求。101 Switching Protocols服务器转换协议&#xff1a;服务器将遵从客户的请求转换到另外一种协议。 2xx: 成功 消息:描述:200…...

CSS之边框样式

让我为大家介绍一下边框样式吧&#xff01;如果大家想更进一步了解边框的使用&#xff0c;可以阅读这一篇文章&#xff1a;CSS边框border 属性描述none没有边框,即忽略所有边框的宽度(默认值)solid边框为单实线dashed边框为虚线dotted边框为点线double边框为双实线 代码演示&…...

k8s-helm

Helm: 什么是helm,在没有这个heml之前&#xff0c;deployment service ingress的作用就是通过打包的方式&#xff0c;把deployment service ingress这些打包在一块&#xff0c;一键式的部署服务&#xff0c;类似于yum 官方提供的一个类似于安全仓库的功能&#xff0c;可以实现…...

黑马程序员JavaWeb开发|Maven高级

一、分模块设计与开发 分模块设计&#xff1a; 将项目按照功能拆分成若干个子模块&#xff0c;方便项目的管理维护、扩展&#xff0c;也方便模块间的相互调用&#xff0c;资源共享。 注意&#xff1a;分模块开发需要先对模块功能进行设计&#xff0c;再进行编码。不会先将工…...

【经验分享】MAC系统安装R和Rstudio(保姆级教程)安装下载只需5min

最近换了Macbook的Air电脑&#xff0c;自然要换很多新软件啦&#xff0c;首先需要安装的就是R和Rstudio啦&#xff0c;网上的教程很多很繁琐&#xff0c;为此我特意总结了最简单实用的安装方式: 一、先R后Rstudio 二、R下载 下载网址&#xff1a;https://cran.r-project.org …...

探索设计模式的魅力:“感受单例模式的力量与神秘” - 掌握编程的王牌技巧

在软件开发的赛场上&#xff0c;单例模式以其独特的魅力长期占据着重要的地位。作为设计模式中的一员&#xff0c;它在整个软件工程的棋盘上扮演着关键性角色。本文将带你深入探索单例模式的神秘面纱&#xff0c;从历史渊源到现代应用&#xff0c;从基础实现到高级技巧&#xf…...

SpringCloud Aliba-Seata【上】-从入门到学废【7】

目录 &#x1f9c2;.Seata是什么 &#x1f32d;2.Seata术语表 &#x1f953;3.处理过程 &#x1f9c8;4.下载 &#x1f37f;5.修改相关配置 &#x1f95e;6.启动seata 1.Seata是什么 Seata是一款开源的分布式事务解决方案&#xff0c;致力于在微服务架构下提供高性能…...

C# Cad2016二次开发选择csv导入信息(七)

//选择csv导入信息 [CommandMethod("setdata")] //本程序在AutoCAD的快捷命令是"DLLLOAD" public void setdata() {Microsoft.Win32.OpenFileDialog dlg new Microsoft.Win32.OpenFileDialog();dlg.DefaultExt ".csv";// Display OpenFileDial…...

[陇剑杯 2021]日志分析

[陇剑杯 2021]日志分析 题目做法及思路解析&#xff08;个人分享&#xff09; 问一&#xff1a;单位某应用程序被攻击&#xff0c;请分析日志&#xff0c;进行作答&#xff1a; 网络存在源码泄漏&#xff0c;源码文件名是_____________。(请提交带有文件后缀的文件名&…...

Java面试汇总——jvm篇

目录 JVM的组成&#xff1a; 1、JVM 概述(⭐⭐⭐⭐) 1.1 JVM是什么&#xff1f; 1.2 JVM由哪些部分组成&#xff0c;运行流程是什么&#xff1f; 2、什么是程序计数器&#xff1f;(⭐⭐⭐⭐) 3、介绍一下Java的堆(⭐⭐⭐⭐) 4、虚拟机栈(⭐⭐⭐⭐) 4.1 什么是虚拟机栈&…...

数据结构:完全二叉树(递归实现)

如果完全二叉树的深度为h&#xff0c;那么除了第h层外&#xff0c;其他层的节点个数都是满的&#xff0c;第h层的节点都靠左排列。 完全二叉树的编号方法是从上到下&#xff0c;从左到右&#xff0c;根节点为1号节点&#xff0c;设完全二叉树的节点数为sum&#xff0c;某节点编…...

观成科技:隐蔽隧道工具Ligolo-ng加密流量分析

1.工具介绍 Ligolo-ng是一款由go编写的高效隧道工具&#xff0c;该工具基于TUN接口实现其功能&#xff0c;利用反向TCP/TLS连接建立一条隐蔽的通信信道&#xff0c;支持使用Let’s Encrypt自动生成证书。Ligolo-ng的通信隐蔽性体现在其支持多种连接方式&#xff0c;适应复杂网…...

第19节 Node.js Express 框架

Express 是一个为Node.js设计的web开发框架&#xff0c;它基于nodejs平台。 Express 简介 Express是一个简洁而灵活的node.js Web应用框架, 提供了一系列强大特性帮助你创建各种Web应用&#xff0c;和丰富的HTTP工具。 使用Express可以快速地搭建一个完整功能的网站。 Expre…...

QMC5883L的驱动

简介 本篇文章的代码已经上传到了github上面&#xff0c;开源代码 作为一个电子罗盘模块&#xff0c;我们可以通过I2C从中获取偏航角yaw&#xff0c;相对于六轴陀螺仪的yaw&#xff0c;qmc5883l几乎不会零飘并且成本较低。 参考资料 QMC5883L磁场传感器驱动 QMC5883L磁力计…...

ssc377d修改flash分区大小

1、flash的分区默认分配16M、 / # df -h Filesystem Size Used Available Use% Mounted on /dev/root 1.9M 1.9M 0 100% / /dev/mtdblock4 3.0M...

《用户共鸣指数(E)驱动品牌大模型种草:如何抢占大模型搜索结果情感高地》

在注意力分散、内容高度同质化的时代&#xff0c;情感连接已成为品牌破圈的关键通道。我们在服务大量品牌客户的过程中发现&#xff0c;消费者对内容的“有感”程度&#xff0c;正日益成为影响品牌传播效率与转化率的核心变量。在生成式AI驱动的内容生成与推荐环境中&#xff0…...

Spring AI 入门:Java 开发者的生成式 AI 实践之路

一、Spring AI 简介 在人工智能技术快速迭代的今天&#xff0c;Spring AI 作为 Spring 生态系统的新生力量&#xff0c;正在成为 Java 开发者拥抱生成式 AI 的最佳选择。该框架通过模块化设计实现了与主流 AI 服务&#xff08;如 OpenAI、Anthropic&#xff09;的无缝对接&…...

OpenLayers 分屏对比(地图联动)

注&#xff1a;当前使用的是 ol 5.3.0 版本&#xff0c;天地图使用的key请到天地图官网申请&#xff0c;并替换为自己的key 地图分屏对比在WebGIS开发中是很常见的功能&#xff0c;和卷帘图层不一样的是&#xff0c;分屏对比是在各个地图中添加相同或者不同的图层进行对比查看。…...

在QWebEngineView上实现鼠标、触摸等事件捕获的解决方案

这个问题我看其他博主也写了&#xff0c;要么要会员、要么写的乱七八糟。这里我整理一下&#xff0c;把问题说清楚并且给出代码&#xff0c;拿去用就行&#xff0c;照着葫芦画瓢。 问题 在继承QWebEngineView后&#xff0c;重写mousePressEvent或event函数无法捕获鼠标按下事…...

Vite中定义@软链接

在webpack中可以直接通过符号表示src路径&#xff0c;但是vite中默认不可以。 如何实现&#xff1a; vite中提供了resolve.alias&#xff1a;通过别名在指向一个具体的路径 在vite.config.js中 import { join } from pathexport default defineConfig({plugins: [vue()],//…...

HybridVLA——让单一LLM同时具备扩散和自回归动作预测能力:训练时既扩散也回归,但推理时则扩散

前言 如上一篇文章《dexcap升级版之DexWild》中的前言部分所说&#xff0c;在叠衣服的过程中&#xff0c;我会带着团队对比各种模型、方法、策略&#xff0c;毕竟针对各个场景始终寻找更优的解决方案&#xff0c;是我个人和我司「七月在线」的职责之一 且个人认为&#xff0c…...