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

string的模拟实现

string的模拟实现

    • msvc和g++下的string内存比较
    • 成员变量
    • 构造函数与析构函数
    • 拷贝构造函数
    • 赋值拷贝
    • c_str、size和capacity函数以及重载[]、clear、expand_capacity
    • 迭代器与遍历
    • reserve
    • push_back、append、+=
    • insert
    • 字符串比较运算符
    • erase
    • <<流提取 >>流插入
    • resize
    • find
    • substr
    • 源码地址


msvc和g++下的string内存比较

int main()
{std::string str1("HelloWorld");std::string str2("HelloWorldHelloWorld");cout << sizeof(str1) << " " << sizeof(str2) << endl;return 0;
}

在windows下使用vs2022 x64运行输出都为40字节:调试上面程序,在自动窗口中观察str1和str2的原始视图:
在这里插入图片描述

发现buf是包含16个字符的数组,里面存放了字符串,ptr为空,size和res分别为字符个数和容量。

而查看str2的字符串视图:发现buf数组为随机值,ptr指向实际的字符串,size和res分别为字符个数和容量。

在这里插入图片描述

MSVC编译器使用的string类内存模型可大概表示如下:

class string
{
private:char _buf[16];char* _ptr;size_t _size;size_t _capacity;
};

在64位下是40字节。


在g++11.4.0版本下运行结果为32字节。可以验证g++和vs2022的msvc都没有使用写拷贝:

int main() {string str1("hello world");string str2(str1);cout << (void *) str1.c_str() << endl; // 0xe8ce3ff7e0cout << (void *) str2.c_str() << endl; // 0xe8ce3ff7c0return 0;
}

现在我们来探索一下g++下的string内存结构:

int main() {std::string s1 = "HelloWorld";std::string s2 = "HelloWorldHelloWorld";std::string s3 = "HelloWorldHelloWorldHelloWorld";cout << (void *) &s1 << " " << (void *) s1.c_str() << endl;cout << (void *) &s2 << " " << (void *) s2.c_str() << endl;cout << (void *) &s3 << " " << (void *) s3.c_str() << endl;return 0;
}
# 观察到s1的内存
0x00000000005ffe10   20 fe 5f 00   00 00 00 00   │  ·_····· │ 
0x00000000005ffe18   0a 00 00 00   00 00 00 00   │ ········ │
0x00000000005ffe20   48 65 6c 6c   6f 57 6f 72   │ HelloWor │
0x00000000005ffe28   6c 64 00 00   01 00 00 00   │ ld······ │
---------------------------------------------------------------------
# 观察到s2的内存
0x00000000005ffdf0   40 47 70 00   00 00 00 00   │ @Gp····· │
0x00000000005ffdf8   14 00 00 00   00 00 00 00   │ ········ │
0x00000000005ffe00   14 00 00 00   00 00 00 00   │ ········ │
0x00000000005ffe08   45 15 8c be   f7 7f 00 00   │ E······· │# s2指向的字符串
0x0000000000704740   48 65 6c 6c   6f 57 6f 72   │ HelloWor │
0x0000000000704748   6c 64 48 65   6c 6c 6f 57   │ ldHelloW │
0x0000000000704750   6f 72 6c 64   00 ab ab ab   │ orld···· │ 
---------------------------------------------------------------------    
# 观察到s3的内存
0x00000000005ffdd0   90 47 70 00   00 00 00 00   │ ·Gp····· │ # 指向字符数组
0x00000000005ffdd8   1e 00 00 00   00 00 00 00   │ ········ │ # size
0x00000000005ffde0   1e 00 00 00   00 00 00 00   │ ········ │ # capacity
0x00000000005ffdd8   00 00 00 00   00 00 00 00   │ ········ │# s3指向的字符串
0x0000000000704790   48 65 6c 6c   6f 57 6f 72   │ HelloWor │
0x0000000000704798   6c 64 48 65   6c 6c 6f 57   │ ldHelloW │
0x00000000007047a0   6f 72 6c 64   48 65 6c 6c   │ orldHell │
0x00000000007047a8   6f 57 6f 72   6c 64 00 ab   │ oWorld·· │

观察上面3个string对象我们知道,第一个成员是char*的_str,指向保存的字符串地址。第二个成员是size。如果是小于等于15个字符,则后面16个字节保存短字符串。如果是大于15个字符的字符串,则第三个成员保存capacity容量,第四个成员则没有意义。

// 短字符串
class string {
private:char* _str;size_t _size;char _buf[16];
};// 长字符串
class string {
private:char* _str;size_t _size;size_t _capacity;size_t _reserve;
};

验证猜想:

int main() {std::string s1 = "HelloWorldHello";std::string s2 = "HelloWorldHelloWorld";std::string s3 = "HelloWorldHelloWorldHelloWorld";cout << (void *) &s1 << " " << (void *) s1.c_str() << " " << s1.size() << " " << s1.capacity() << endl;cout << (void *) &s2 << " " << (void *) s2.c_str() << " " << s2.size() << " " << s2.capacity() << endl;cout << (void *) &s3 << " " << (void *) s3.c_str() << " " << s3.size() << " " << s3.capacity() << endl;s1.push_back('*'); // 插入数据扩容cout << (void *) &s1 << " " << (void *) s1.c_str() << " " << s1.size() << " " << s1.capacity() << endl;s3.push_back('*'); // 插入数据扩容cout << (void *) &s3 << " " << (void *) s3.c_str() << " " << s3.size() << " " << s3.capacity() << endl;return 0;
}
/*
0xdd031ffde0 0xdd031ffdf0 15 15    # 扩容前s1
0xdd031ffdc0 0x2a486af25b0 20 20   # s2
0xdd031ffda0 0x2a486af6820 30 30   # s3
0xdd031ffde0 0x2a486af7860 16 30   # 扩容后s1
0xdd031ffda0 0x2a486af7890 31 60   # 扩容后s3
*/

成员变量

为了简单模拟字符串,我们不像g++和msvc一样保留对短字符串的处理,我们定义如下几个变量:

namespace my_std
{class string{private:char* _str; // 字符串数组size_t _size;size_t _capacity;static const size_t npos;};const size_t string::npos = -1;
}
// size:当前有效字符的个数
// capacity:最大能容纳的有效字符的个数,不包括\0

在自己的命名空间 my_std 中实现,防止与std冲突。

下面我们将模拟g++下的string,可以对照g++的string输出作为参考。

构造函数与析构函数

std标准库中string构造函数的使用:

int main() {std::string s1 = "HelloWorldHello";std::string s2 = "HelloWorldHelloWorld";std::string s3 = "HelloWorldHelloWorldHelloWorld";cout << (void *) &s1 << " " << (void *) s1.c_str() << " " << s1.size() << " " << s1.capacity() << endl;cout << (void *) &s2 << " " << (void *) s2.c_str() << " " << s2.size() << " " << s2.capacity() << endl;cout << (void *) &s3 << " " << (void *) s3.c_str() << " " << s3.size() << " " << s3.capacity() << endl;return 0;
}
/*
0x84b4fff660 0x84b4fff670 15 15
0x84b4fff640 0x23a3caa25b0 20 20
0x84b4fff620 0x23a3caa6820 30 30
*/

我们模拟实现如下:这里的默认参数旨在一个string空对象的正确打印。

string(const char* str = ""): _size(strlen(str))
{_capacity = (_size <= 15) ? 15 : _size;_str = new char[_capacity + 1];strcpy(_str, str);
}

如果是短字符串,我们将容量设置为15。如果是长字符串,容量设置为实际长度。

这里需要注意strcpy会拷贝 '\0'


下面是析构函数实现:因为构造函数中我们保证了容量至少是15,并且下面的实现resize中即使缩容也不会影响capacity实际容量,因此 _str不会为空。可以不加 _str 为空的判断。

~string()
{delete[] _str;_str = nullptr;_size = _capacity = 0;
}

拷贝构造函数

先看标准库中string的使用:

void test() {std::string str = "helloworldhelloworld";cout << str.size() << " " << str.capacity() << " " << (void *) str.c_str() << endl; // 20 20 0x18ff84f25b0str.push_back('#');cout << str.size() << " " << str.capacity() << " " << (void *) str.c_str() << endl; // 21 40 0x18ff84f7830std::string str1 = str;cout << str1.size() << " " << str1.capacity() << " " << (void *) str1.c_str() << endl; // 21 21 0x18ff84f25b0}int main() {test();return 0;
}

可以观察到拷贝构造的str1的size和capacity都等于str的size,因此可以实现如下:

string(const string& s)
{// apply the new space_size = s._size;_capacity = s._size;_str = new char[_capacity + 1];// copy strstrcpy(_str, s.c_str());
}

赋值拷贝

先看g++下的赋值拷贝:

void test() {string str = "helloworldhelloworld";cout << "str:" << str.size() << " " << str.capacity() << " " << (void *) str.c_str() << endl;str.push_back('#');cout << "str插入#:" << str.size() << " " << str.capacity() << " " << (void *) str.c_str() << endl;string str1;cout << "str1扩容前:" << str1.size() << " " << str1.capacity() << " " << (void *) str1.c_str() << endl;string str2 = "Hello";cout << str2.size() << " " << str2.capacity() << " " << (void *) str2.c_str() << endl;// 短字符串 原地复制str1 = str2;cout << "str1短字符串原地复制:" << str1.size() << " " << str1.capacity() << " " << (void *) str1.c_str() << endl;// 长字符串 两倍扩容str1 = str;cout << "str1长字符串两倍扩容:" << str1.size() << " " << str1.capacity() << " " << (void *) str1.c_str() << endl;str += "helloworldhelloworld";cout << str.size() << " " << str.capacity() << " " << (void *) str.c_str() << endl;// 长字符串 两倍扩容不够 扩容到s.size()string str3;cout << "str3扩容前:" << str3.size() << " " << str3.capacity() << " " << (void *) str3.c_str() << endl;str3 = str;cout << "str3扩容后:" << str3.size() << " " << str3.capacity() << " " << (void *) str3.c_str() << endl;}int main() {test();return 0;
}
/*
str:20 20 0x17f061725b0
str插入#:21 40 0x17f06177830
str1扩容前:0 15 0x4dc55ffbc0
5 15 0x4dc55ffba0
str1短字符串原地复制:5 15 0x4dc55ffbc0
str1长字符串两倍扩容:21 30 0x17f061725b0
41 80 0x17f06177870
str3扩容前:0 15 0x4dc55ffb80
str3扩容后:41 41 0x17f06177830
*/

在等号赋值的过程中,如果赋值的字符串较短,则在原来的内存空间中直接复制。否则发生扩容,如果两倍扩容不够,则扩容到s._size。

string& operator=(const string& s)
{if (&s != this){if (s._size > _capacity){// 两倍扩容不够,则扩容到s._size_capacity = (s._size > 2 * _capacity) ? s._size : 2 * _capacity;delete[] _str;_str = new char[_capacity + 1];}strcpy(_str, s._str);_size = s._size;}return *this;
}

下面写了reserve函数之后可以修改为:代码上更简洁,但是多了一次拷贝。

string& operator=(const string& s)
{if (&s != this){reserve(s._size);strcpy(_str, s._str);_size = s._size;}return *this;
}

c_str、size和capacity函数以及重载[]、clear、expand_capacity

const char* c_str() const
{return _str;
}size_t size() const
{return _size;
}size_t capacity() const
{return _capacity;
}char& operator[](size_t pos)
{assert(pos < _size);return _str[pos];
}const char& operator[](size_t pos) const
{assert(pos < _size);return _str[pos];
}

这里还专门针对const string对象写了重载[]的const成员函数。


void expand_capacity(std::string &str) {size_t old_capacity = str.capacity();cout << "init capacity: " << old_capacity << endl;for (int i = 0; i < 100; ++i) {str.append("h");//str.push_back('h');if (old_capacity != str.capacity()) {old_capacity = str.capacity();cout << "expand capacity: " << old_capacity << endl;}}
}int main() {string str;expand_capacity(str);cout << str.size() << " " << str.capacity() << endl;str.clear();cout << str.size() << " " << str.capacity() << endl;return 0;
}
/*
init capacity: 15
expand capacity: 30
expand capacity: 60
expand capacity: 120
100 120
0 120
*/

clear函数将size置0,容量保留:

void clear()
{_str[0] = '\0';_size = 0;
}

迭代器与遍历

class string
{
public:typedef char* iterator;iterator begin(){return _str;}iterator end(){return _str + _size;}
}

测试:

int main()
{// 遍历测试string str1("hello world");cout << str1.c_str() << endl;for (size_t i = 0; i < str1.size(); ++i){cout << str1[i] << " ";}cout << endl;string::iterator it = str1.begin();while (it != str1.end()){cout << *it << " ";++it;}cout << endl;for (auto ch : str1){cout << ch << " ";}cout << endl;return 0;
}

reserve

void test() {string s = "hello";cout << s.size() << " " << s.capacity() << " " << s << endl;s.reserve(5);cout << "(05)" << s.size() << " " << s.capacity() << " " << s << endl;s.reserve(18);cout << "(18)" <<  s.size() << " " << s.capacity() << " " << s << endl;s.reserve(61);cout << "(61)" <<  s.size() << " " << s.capacity() << " " << s << endl;
}int main() {test();return 0;
}
/*
5 15 hello
(05)5 15 hello
(18)5 30 hello
(61)5 61 hello
*/

标准库中的reserve函数的使用,reserve参数如果比capacity小,则没有变化。reserve参数比capacity大,发生扩容,如果两倍扩容不够,则扩容到输入的参数。

void reserve(size_t n)
{if (n > _capacity){// 两倍扩容不够,则扩容到n_capacity = (n > 2 * _capacity) ? n : 2 * _capacity;char* tmp = new char[_capacity + 1];strcpy(tmp, _str);delete[] _str;_str = tmp;}
}

push_back、append、+=

void push_back(char ch)
{/*if (_size == _capacity){reserve(_capacity * 2);}*/reserve(_size + 1);_str[_size++] = ch;_str[_size] = '\0';
}void append(const char* str)
{size_t len = strlen(str);reserve(_size + len);strcpy(_str + _size, str);_size += len;
}string& operator+=(const char* str)
{append(str);return *this;
}string& operator+=(char ch)
{push_back(ch);return *this;
}

值得说的是,有了上面的reserve,我们在扩容时,代码上就可以更简洁,不用进行 _size == _capacity 的判断:

void push_back(char ch)
{/*if (_size == _capacity){reserve(_capacity * 2);}*/reserve(_size + 1);_str[_size++] = ch;_str[_size] = '\0';
}

insert

要从 '\0' 开始向后移动,使用时注意while循环对size_t类型的判断,避免导致死循环:

void insert(size_t pos, char ch)
{assert(pos <= _size);reserve(_size + 1);/*size_t end = _size; // from '\0' startwhile (end >= pos)  // when pos=0, while loop will not exit{_str[end + 1] = _str[end];--end;}*/size_t end = _size + 1; // from '\0' next pos startwhile (end > pos){_str[end] = _str[end - 1];--end;}_str[pos] = ch;_size++;
}

下面是插入字符串str:

void insert(size_t pos, const char* str)
{assert(pos <= _size);size_t len = strlen(str);reserve(_size + len);// 向后挪动数据size_t end = _size + 1; // from '\0' next pos startwhile (end > pos){_str[end - 1 + len] = _str[end - 1];--end;}// 拷贝数据/*for (int i = 0; i < len; ++i){_str[i + pos] = str[i];}*/strncpy(_str + pos, str, len);_size += len;
}

这里使用 strncpy 指定拷贝的字节数。

字符串比较运算符

bool operator<(const string& s) const
{return strcmp(_str, s._str) < 0;
}bool operator==(const string& s) const
{return strcmp(_str, s._str) == 0;
}bool operator<=(const string& s) const
{return *this < s || *this == s;
}bool operator>(const string& s) const
{return !(*this <= s);
}bool operator>=(const string& s) const
{return !(*this < s);
}bool operator!=(const string& s) const
{return !(*this == s);
}

erase

void erase(size_t pos, size_t len = npos)
{assert(pos < _size);if (len == npos || pos + len >= _size){// 从pos删除到结尾_str[pos] = '\0';_size = pos;}else{// 从pos删除len长度个strcpy(_str + pos, _str + pos + len);_size -= len;}
}

验证:

int main()
{string str1("helloworld");cout << str1 << " " << str1.size() << " " << str1.capacity() << endl;str1.erase(6);cout << str1 << " " << str1.size() << " " << str1.capacity() << endl;str1.erase(0);cout << str1 << " " << str1.size() << " " << str1.capacity() << endl;return 0;
}/*
helloworld 10 15
hellow 6 150 15
*/

<<流提取 >>流插入

将<<和 >> 重载为全局函数,放在my_std命名空间中:

std::ostream& operator <<(std::ostream& out, const string& s)
{out << s.c_str();return out;
}

使用 istream::get() 方法,每次读取一个字符进行插入。

std::istream& operator>>(std::istream& in, string& s)
{s.clear();char ch;// in >> ch;ch = in.get(); // istream::get()while (ch != ' ' && ch != '\n'){s += ch;ch = in.get();}return in;
}

每次字符串执行+= s += ch; 效率太低,我们加入buf,提高插入的效率:

std::istream& operator>>(std::istream& in, string& s)
{s.clear();char buf[128] = { '\0' };size_t i = 0;char ch;// in >> ch;ch = in.get(); // istream::get()while (ch != ' ' && ch != '\n'){//s += ch;if (i == 127){s += buf;i = 0;}buf[i] = ch;i++;ch = in.get();}if (i >= 0){buf[i] = '\0';s += buf;}return in;
}

resize

cplusplus的resize

void resize (size_t n);
void resize (size_t n, char c);
int main()
{//test_main();string s1("hello world");cout << s1 << " " << s1.size() << " " << s1.capacity() << endl;s1.resize(5);cout << s1 << " " << s1.size() << " " << s1.capacity() << endl;s1.resize(50, 'x');cout << s1 << " " << s1.size() << " " << s1.capacity() << endl;return 0;
}
/*
hello world 11 15
hello 5 15
helloxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 50 50
*/

假设有字符串 str = "hello world" 的size为11,capacity为10。

针对以下三种参数调整空间:

1.当n=5时,也就是n<=size,可以直接令 str[5] = '\0',size变为5,容量不变。

2.当n=15时,也就是n>size,需要插入数据,直接调用reserve扩容为n个空间,然后将剩下的插入指定字符c。

我们自己实现的resize:

void resize(size_t n, char ch = '\0')
{if (n <= _size){_str[n] = '\0';_size = n;}else{reserve(n);while (_size < n){_str[_size] = ch;++_size;}_str[_size] = '\0';}
}

find

find返回指定字符或者字符串从pos开始的下标:

size_t find(char ch, size_t pos = 0)
{for (size_t i = pos; i < _size; i++){if (_str[i] == ch){return i;}}return npos;
}size_t find(const char* sub, size_t pos = 0)
{const char* p = strstr(_str + pos, sub);if (p){return p - _str;}else{return npos;}
}

substr

cplusplus.com/reference/string/string/substr/

string substr (size_t pos = 0, size_t len = npos) const;

实现如下:

string substr(size_t pos, size_t len = npos)
{string s;size_t end = pos + len;if (len == npos || end >= _size) // 取到结尾{// len为字串的sizelen = _size - pos; // end >=_sizeend = _size;}s.reserve(len);for (size_t i = pos; i < end; i++){s += _str[i];}return s;
}

值得说的是从pos开始指定取的len如果太长超过结尾,则需要修正取到的len的大小。

源码地址

https://github.com/shlyyy/stl/blob/main/my_string.h

https://gitee.com/shlyyy/stl/blob/master/my_string.h

相关文章:

string的模拟实现

string的模拟实现 msvc和g下的string内存比较成员变量构造函数与析构函数拷贝构造函数赋值拷贝c_str、size和capacity函数以及重载[]、clear、expand_capacity迭代器与遍历reservepush_back、append、insert字符串比较运算符erase<<流提取 >>流插入resizefindsubst…...

算法练习:查找二维数组中的目标值

题目&#xff1a; 编写一个高效的算法来搜索矩阵 matrix 中的一个目标值 target 。该矩阵具有以下特性&#xff1a;每行的元素从左到右升序排列。每列的元素从上到下升序排列。 实现&#xff1a; 1. main方法 public static void main(String[] args) {int[][] matrix {{1…...

考研自命题资料、考题如何找

这篇文章是抖音和b站上上传的同名视频的原文稿件&#xff0c;感兴趣的csdn用户可以关注我的抖音和b站账号&#xff08;GeekPower极客力量&#xff09;。同时这篇文章也为视频观众提供方便&#xff0c;可以更加冷静地分析和思考。文章同时在知乎发表。 去年我发布了一个视频&am…...

MySQL 存储引擎和索引类型介绍

1. 引言 MySQL 是一个流行的关系型数据库管理系统&#xff0c;提供多种存储引擎以满足不同的业务需求。本文将介绍几种常见的 MySQL 存储引擎和索引类型比较&#xff0c;并给出相应的示例。 2. 存储引擎概述 2.1 InnoDB 存储引擎 InnoDB 是 MySQL 的默认存储引擎&#xff0…...

element-ui table height 属性导致界面卡死

问题: 项目上&#xff0c;有个点击按钮弹出抽屉的交互, 此时界面卡死 原因分析: 一些场景下(父组件使用动态单位/弹窗、抽屉中使用), element-ui 的 table 会循环计算高度值, 导致界面卡死 github 上的一些 issues 和解决方案: Issues ElemeFE/element GitHub 官方讲是升…...

Vue2.v-指令

v-if 在双引号中写判断条件。 <div v-if"score>90">A</div> <div v-else-if"score>80">B</div> <div v-else>C</div>v-on: :冒号后面跟着事件。 为了简化&#xff0c;可以直接用代替v-on:。 事件名“内联语…...

Java中SpringBoot组件集成接入【Knife4j接口文档(swagger增强)】

Java中SpringBoot组件集成接入【Knife4j接口文档】 1.Knife4j介绍2.maven依赖3.配置类4.常用注解使用1.实体类及属性(@ApiModel和@ApiModelProperty)2.控制类及方法(@Api、@ApiOperation、@ApiImplicitParam、 @ApiResponses)3.@ApiOperationSupport注解未生效的解决方法5.…...

继承和多态的详解

文章目录 1. 继承1.1 继承的概念1.3 继承的语法1.3 父类成员访问1.3.1 子类中访问父类的成员变量1.3.2 子类中访问父类的成员方法 1.4 子类构造方法 2.super关键字2.1 super关键字的概念2.2 super和this的区别 3. 在继承中访问限定符的可见性4. 继承方式的分类5. 多态5.1 多态的…...

【Unity】UniTask(异步工具)快速上手

UniTask(异步工具) 官方文档&#xff1a;https://github.com/Cysharp/UniTask/blob/master/README_CN.md URL:https://github.com/Cysharp/UniTask.git?pathsrc/UniTask/Assets/Plugins/UniTask 优点&#xff1a;0GC&#xff0c;可以在任何地方使用 为Unity提供一个高性能&…...

k8s三种常用的项目发布方式

k8s三种常用的项目发布方式 1、 蓝绿发布 2、 金丝雀发布(灰度发布)&#xff1a;使用最多 3 、滚动发布 应用程序升级&#xff0c;面临的最大问题是新旧业务之间的切换。 项目的生命周期&#xff1a;立项----定稿----需求发布----开发----测试-----发布 最后测试之后上线。再…...

Nodejs搭配axios下载图片

新建一个文件夹&#xff0c;npm i axios 实测发现只需保留node_modules文件夹&#xff0c;删除package.json不影响使用 1.纯下载图片 其实该方法不仅可以下载图片&#xff0c;其他的文件都可以下载 const axios require(axios) const fs require(fs) var arrPic [https:…...

强化学习在生成式预训练语言模型中的研究现状简单调研

1. 绪论 本文旨在深入探讨强化学习在生成式预训练语言模型中的应用&#xff0c;特别是在对齐优化、提示词优化和经验记忆增强提示词等方面的具体实践。通过对现有研究的综述&#xff0c;我们将揭示强化学习在提高生成式语言模型性能和人类对话交互的关键作用。虽然这些应用展示…...

python_selenium_安装基础学习

目录 1.为什么使用selenium 2.安装selenium 2.1Chrome浏览器 2.2驱动 2.3下载selenium 2.4测试连接 3.selenium元素定位 3.1根据id来找到对象 3.2根据标签属性的属性值来获取对象 3.3根据xpath语句来获取对象 3.4根据标签的名字获取对象 3.5使用bs4的语法来获取对象…...

面试宝典进阶之关系型数据库面试题

D1、【初级】你都使用过哪些数据库&#xff1f; &#xff08;1&#xff09;MySQL&#xff1a;开源数据库&#xff0c;被Oracle公司收购 &#xff08;2&#xff09;Oracle&#xff1a;Oracle公司 &#xff08;3&#xff09;SQL Server&#xff1a;微软公司 &#xff08;4&#…...

Agisoft Metashape 地面点分类参数设置

Agisoft Metashape 点云分类之地面点分类参数设置 文章目录 Agisoft Metashape 点云分类之地面点分类参数设置前言一、分类地面点参数二、农村及城区有房屋地区二、植被区域分类三、侵蚀半径(Erosion radius)参数设置前言 Agisoft Metashape提供了自动检测地面点的功能,减少…...

计算机科学速成课【学习笔记】(4)——二进制

本集课程B站链接&#xff1a; 4. 二进制-Representing Numbers and Letters with Binary_BiliBili_哔哩哔哩_bilibili4. 二进制-Representing Numbers and Letters with Binary_BiliBili是【计算机科学速成课】[40集全/精校] - Crash Course Computer Science的第4集视频&…...

数据库开发工具Navicat Premium 15 mac软件特色

Navicat Premium 15 mac版是一款数据库开发工具&#xff0c;Navicat Premium 15 Mac版可以让你以单一程序同時连接到 MySQL、MariaDB、SQL Server、SQLite、Oracle 和 PostgreSQL 数据库。 Navicat Premium mac软件特色 无缝数据迁移 数据传输&#xff0c;数据同步和结构同步…...

从零开始构建区块链:我的区块链开发之旅

1.引言 1.区块链技术的兴起和重要性 区块链技术&#xff0c;作为数字化时代的一项颠覆性创新&#xff0c;已经成为当今世界最令人瞩目的技术之一。自比特币的问世以来&#xff0c;区块链技术已经从仅仅支持加密货币发展成为一种具有广泛应用前景的分布式账本技术。其核心优势…...

c JPEG编码,但有错误

#include <stdio.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <stdlib.h> #include <unistd.h> #include <sys/ioctl.h> #include <linux/videodev2.h> //v4l2 头文件 #include <strin…...

二级C语言备考1

一、单选 共40题 &#xff08;共计40分&#xff09; 第1题 &#xff08;1.0分&#xff09; 题号:6923 难度:较易 第1章 以下叙述中正确的是 A:C语言规定必须用main作为主函数名,程序将从此开始执行 B:可以在程序中由用户指定任意一个函数作为主函数…...

【2024系统架构设计】 系统架构设计师第二版-嵌入式系统架构设计理论与实践

目录 一 嵌入式系统软件架构的原理 二 嵌入式系统软件架构的设计方法 三 案例分析 一 嵌入式系统软件架构的原理 🚀嵌入式系统的典型架构可以分为...

用python提取word中的所有图片

使用word中提取的方式图片会丢失清晰度&#xff0c;使用python写一个脚本&#xff0c;程序运行将弹出对话框选择一个word文件&#xff0c;然后在弹出一个对话框选择一个文件夹保存word中的文件。将该word中的所有图片都保存成png格式&#xff0c;并命名成image_i的样式。 程序…...

医疗器械分类及是否需要临床

1、医疗器械的分类&#xff1a; 在中国&#xff0c;医疗器械的管理分为一类、二类和三类&#xff0c;这是根据《医疗器械监督管理条例》的规定划分的。不同类别的医疗器械受到不同的监督和管理&#xff0c;包括注册审批、生产质量监督、市场监管等方面。 一类医疗器械&#x…...

AI人工智能虚拟现实行业发展分析

AI人工智能和虚拟现实是当今科技领域最受关注和研究的两个领域。这两项技术的迅速发展给各行各业带来了巨大的变革和机遇。在过去的几年里&#xff0c;AI和虚拟现实已经取得了显著的进展&#xff0c;并且有着广阔的发展前景。 AI人工智能作为一种模拟人类智能的技术&#xff0…...

3. SPSS数据文件的基本加工和处理

如何获取SPSS自带的案例数据文件&#xff1f; 首先找到SPSS的安装目录&#xff0c;然后找到Samples文件夹 可以看到有不同语言版本&#xff0c;选择简体中文 就能看到很多.sav文件 数据文件的整理 个案排序 单值排序 例&#xff1a;对于下面的数据集&#xff0c;将工资按…...

Ubuntu20二进制方式安装nginx

文章目录 1.下载nginx安装包2.安装nginx3.安装出现的问题及解决方案错误1&#xff1a;错误2&#xff1a;错误3&#xff1a; 4.常用命令5.知识扩展&#xff1a; 1.下载nginx安装包 nginx官网&#xff1a;http://nginx.org/en/download.html 选择稳定的nginx版本下载。 2.安装ngi…...

window mysql5.7 搭建主从同步环境

window 搭建mysql5.7数据库 主从同步 主节点 配置文件my3308.cnf [mysql] # 设置mysql客户端默认字符集 default-character-setutf8mb4[mysqld] server-id8 #server-uuidbc701be9-ac71-11ee-9e35-b06ebf511956 log-binD:\mysql_5.7.19\mysql-5.7.19-winx64\mysql-bin binlog-…...

MCU、MPU、SOC简介

文章目录 前言一、MCU二、MPU三、SOC总结 前言 随着处理器技术的不断发展&#xff0c;CPU(Central Processing Unit)的发展逐渐出现三种分支&#xff0c;分别是MCU(Micro Controller Unit&#xff0c;微控制器单元) 和MPU&#xff08;Micro Processor Unit&#xff0c;微处理器…...

Kubernetes那点事儿——配置存储:ConfigMap、Secret

配置存储&#xff1a;ConfigMap、Secret 前言ConfigMapSecret 前言 前面介绍过的各种存储主要都是做数据的持久化&#xff0c;本节介绍的ConfigMap和Secret主要用于配置文件存储&#xff0c;或者环境变量的配置。 ConfigMap 创建ConfigMap后&#xff0c;数据实际会存储在K8s中…...

小白向:搭建企业培训APP的完整技术指南

当下&#xff0c;许多企业转向了现代化的培训方法&#xff0c;其中一个关键的工具就是企业培训APP。本文将为你提供搭建企业培训APP的完整技术指南&#xff0c;助你在数字化时代更好地满足企业培训的需求。 一、需求分析与功能规划 在开始开发之前&#xff0c;首先需要明确企…...

CVE-2023-36025 Windows SmartScreen 安全功能绕过漏洞

CVE-2023-36025是微软于11月补丁日发布的安全更新中修复Windows SmartScreen安全功能绕过漏洞。攻击者可以通过诱导用户单击特制的URL来利用该漏洞&#xff0c;对目标系统进行攻击。成功利用该漏洞的攻击者能够绕过Windows Defender SmartScreen检查及其相关提示。该漏洞的攻击…...

分析一个项目(微信小程序篇)二

目录 首页&#xff1a; 发现&#xff1a; 购物车&#xff1a; 我的&#xff1a; 分析一个项目讲究的是如何进行对项目的解析分解&#xff0c;进一步了解项目的整体结构&#xff0c;熟悉项目的结构&#xff0c;能够知道每个组件所处在哪个位置&#xff0c;发挥什么作用。 接…...

每日论文推送(有中文摘或源码地址或项目地址)

***VX搜索“晓理紫”并关注就可以每日获取最新论文***标题: “It’s not like Jarvis, but it’s pretty close!” – Examining ChatGPT’s Usage among Undergraduate Students in Computer Science作者: Ishika Joshi, Ritvik Budhiraja, Harshal D Akolekar摘要: Large lan…...

【漏洞复现】锐捷EG易网关login.php命令注入漏洞

Nx01 产品简介 锐捷EG易网关是一款综合网关&#xff0c;由锐捷网络完全自主研发。它集成了先进的软硬件体系架构&#xff0c;配备了DPI深入分析引擎、行为分析/管理引擎&#xff0c;可以在保证网络出口高效转发的条件下&#xff0c;提供专业的流控功能、出色的URL过滤以及本地化…...

Nginx安装http2和ssl模块

Nginx安装http2和ssl模块 Nginx在执行默认安装命令的时候&#xff0c;并不会编译启用ngx_http_v2_module模块。故在修改Nginx配置文件启用http2.0协议的时候会报错。 一.检查Nginx安装了哪些模块 #进入Nginx的安装目录 cd /usr/local/nginx #执行命令查看安装了哪些模块 ./sbi…...

Android 8.1 隐藏设置中定位功能

Android 8.1 隐藏设置中定位功能 最近接到客户反馈&#xff0c;需要隐藏设备设置中的定位功能&#xff0c;具体修改参照如下&#xff1a; /vendor/mediatek/proprietary/packages/apps/MtkSettings/src/com/android/settings/SecuritySettings.java mLocationcontroller.displ…...

无线网卡怎么连接台式电脑?正确操作步骤分享!

“我在使用电脑时经常都需要用到网络&#xff0c;请问大家在使用无线网卡时怎么将它与台式电脑进行连接的呢&#xff1f;” 使用电脑的用户在进行网上冲浪时都需要先连接网络。如果不想使用网线&#xff0c;无线网卡不仅可以为用户提供网络服务&#xff0c;在使用时该更加灵活和…...

聚道云软件连接器助力某贸易公司实现付款流程自动化

客户介绍&#xff1a; 某贸易公司是一家集进出口贸易、国内贸易、电子商务等业务于一体的综合性贸易企业。公司业务遍及全球多个国家和地区&#xff0c;拥有庞大的供应商网络和采购需求。 添加图片注释&#xff0c;不超过 140 字&#xff08;可选&#xff09; 客户痛点&#…...

第六讲_css盒子模式

css盒子模型 1. 长度单位2. 盒子模型的组成2.1 盒子模型内容2.2 盒子模型内边距2.3 盒子模型边框2.4 盒子模型外边距 1. 长度单位 px&#xff1a;像素em&#xff1a;相对于当前元素或父元素的 font-size 的倍数 <style>.parent {height: 500px;width: 500px;background…...

【WSL】Win10 使用 WSL2 进行 Linux GPU 开发

1. GPU 驱动 先安装 驱动 参考 https://docs.nvidia.com/cuda/wsl-user-guide/index.html 使用 https://www.nvidia.com/Download/index.aspx 提供的兼容 GeForce 或 NVIDIA RTX/Quadro 显卡在系统上安装 NVIDIA GeForce Game Ready 或 NVIDIA RTX Quadro Windows 11 显示驱动…...

什么是博若莱新酒节?

在红酒圈儿里混&#xff0c;一定不能不知道博若莱新酒节&#xff0c;这是法国举世闻名的以酒为主题的重要节日之一。现已成为世界范围内庆祝当年葡萄收获和酿制的节日&#xff0c;被称为一年一度的酒迷盛会。 云仓酒庄的品牌雷盛红酒LEESON分享博若莱位于法国勃艮第南部&#x…...

Centos7下升级gcc/g++版本(简单 + 避坑)

在 Centos7 下&#xff0c;使用 yum 安装高版本的 gcc/g 最简单&#xff1a; yum -y install centos-release-scl yum -y install devtoolset-11-gcc devtoolset-11-gcc-c devtoolset-11-binutils需要安装哪个个版本的gcc/g&#xff0c;就把数字替换成对应的版本号。例如上面代…...

PyTorch项目源码学习(1)

PyTorch PyTorch是一个开源的深度学习框架&#xff0c;项目地址 https://github.com/pytorch/pytorch 在学术工作中的使用频率较高。 其主体由C开发&#xff0c;PyTorch是Torch的Python调用版本。学习PyTorch项目源代码的目的在于学习其中的实现方法与技巧&#xff0c;增加训练…...

adb 使用的出现 adb server is out of date. killing

我知道你们肯定看到这种播客 像这种解决问题的方法是暂时的 , 因为我们Android studio 中 , 你在查看后台的时候发现 你的Android studio 也占用了一端口 , 就是说你把 Android studio 杀掉了只要打开 Android studio 打开就还是 关闭 cmd adb 看到一个新的方法 , win 10 中…...

数据结构之二叉搜索树(Binary Search Tree)

数据结构可视化演示链接&#xff0c;也就是图片演示的网址 系列文章目录 数据结构之AVL Tree 数据结构之B树和B树 数据结构之Radix和Trie 文章目录 系列文章目录示例图定义二叉搜索树满足的条件应用场景 示例图 二叉 线形(顺序插入就变成了线性树&#xff0c;例如插入顺序为&…...

Spring Boot自定义启动Banner在线生成工具

记录一下&#xff0c;后续有更新添加 链接: Spring Boot自定义启动Banner在线生成工具...

Android Studio导入项目 下载gradle很慢或连接超时,提示:Read timed out---解决方法建议收藏!

目录 前言 一、报错信息 二、解决方法 三、更多资源 前言 一般来说&#xff0c;使用Android Studio导入项目并下载gradle的过程应该是相对顺利的&#xff0c;但是有时候会遇到下载速度缓慢或连接超时的问题&#xff0c;这可能会让开发者感到头疼。这种情况通常会出现在网络…...

汽车标定技术(十五)--FETK如何帮助Aurix实现快速原型、标定测量功能(1)

目录 1.概述 2.ETK描述 2.1 产品概述 2.2 FETK-T1.1产品描述 2.3 FETK-T1.1内部构造 3.小结...

linux项目部署(jdk,tomcat,mysql,nginx,redis)

打开虚拟机&#xff0c;与连接工具连接好&#xff0c;创建一个文件夹 cd /tools 把jdk,tomcat安装包放入这个文件夹里面 jdk安装 #解压 tar -zxvf apache-tomcat-8.5.20.tar.gz #解压jdk tar -zxvf jdk-8u151-linux-x64.tar.gz 编辑jdk文件以及测试jdk安装 第一行代码路径…...

Unity | 渡鸦避难所-6 | 有限状态机控制角色行为逻辑

1 有限状态机简介 有限状态机&#xff08;英语&#xff1a;finite-state machine&#xff0c;缩写&#xff1a;FSM&#xff09;&#xff0c;简称状态机&#xff0c;是表示有限个状态以及在这些状态之间的转移和动作等行为的数学计算模型 在游戏开发中应用有限状态机&#xff…...