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

C++——模拟实现list

1.初步实现结点和链表

namespace jxy
{template<class T>struct list_node{T _data;list_node<T>* _prev;list_node<T>* _next;list_node(const T& x = T()):_data(x),_prev(nullptr),_next(nullptr){}};template<class T>class list//list的框架本质是封装+运算符重载{typedef list_node<T> Node;public:void empty_init(){_head = new Node;_head->_next = _head;_head->_prev = _head;}list(){empty_init();}private:Node* _head;size_t _size;
//不写_size变量的话,想获取size的大小,从头遍历链表,时间复杂度是O(N)};
}

2.push_back

namespace jxy
{template<class T>struct list_node{T _data;list_node<T>* _prev;list_node<T>* _next;list_node(const T& x = T()):_data(x),_prev(nullptr),_next(nullptr){}};template<class T>class list//list的框架本质是封装+运算符重载{typedef list_node<T> Node;public:void empty_init(){_head = new Node;_head->_next = _head;_head->_prev = _head;_size = 0;}list(){empty_init();}void push_back(const T& x){Node* tail = _head->_prev;Node* newnode = new Node(x);//调用构造函数tail->_next = newnode;newnode->_prev = tail;newnode->_next = _head;_head->_prev = newnode;}private:Node* _head;size_t _size;};
}

3.初步实现迭代器

将迭代器封装为类来实现其功能

namespace jxy
{template<class T>struct list_node{T _data;list_node<T>* _prev;list_node<T>* _next;list_node(const T& x = T()):_data(x),_prev(nullptr),_next(nullptr){}};template<class T>struct __list_iterator//一般前加__就说明这是内部的实现{typedef list_node<T> Node;typedef __list_iterator<T> self;Node* _node;__list_iterator(Node* node):_node(node){}self& operator++()//不是连续的物理空间,++不能到下一个位置{_node = _node->_next;return *this;}T& operator*(){return _node->_data;}bool operator!=(const self& s){return (_node != s._node);}};template<class T>class list//list的框架本质是封装+运算符重载{typedef list_node<T> Node;public:typedef __list_iterator<T> iterator;iterator begin(){//return iterator(_head->_next);return _head->_next;}iterator end(){//return iterator(_head);return _head;}void empty_init(){_head = new Node;_head->_next = _head;_head->_prev = _head;}list(){empty_init();}void push_back(const T& x){Node* tail = _head->_prev;Node* newnode = new Node(x);//调用构造函数tail->_next = newnode;newnode->_prev = tail;newnode->_next = _head;_head->_prev = newnode;}private:Node* _head;size_t _size;};void test_list1(){list<int> lt;lt.push_back(1);lt.push_back(2);lt.push_back(3);lt.push_back(4);lt.push_back(5);// 封装,屏蔽了底层差异和实现细节// 提供了统一的访问、修改和遍历方式list<int>::iterator it = lt.begin();while (it != lt.end()){*it += 10;//还可以修改cout << *it << " ";++it;}cout << endl;for (auto e : lt){cout << e << " ";}cout << endl;}
}

4.插入和删除

namespace jxy
{template<class T>struct list_node{T _data;list_node<T>* _prev;list_node<T>* _next;list_node(const T& x = T()):_data(x),_prev(nullptr),_next(nullptr){}};template<class T>struct __list_iterator//一般前加__就说明这是内部的实现{typedef list_node<T> Node;typedef __list_iterator<T> self;Node* _node;__list_iterator(Node* node):_node(node){}self& operator++()//不是连续的物理空间,++不能到下一个位置{_node = _node->_next;return *this;}T& operator*(){return _node->_data;}bool operator!=(const self& s){return (_node != s._node);}};template<class T>class list//list的框架本质是封装+运算符重载{typedef list_node<T> Node;public:typedef __list_iterator<T> iterator;void clear()//不清哨兵位的头结点{iterator it = begin();while (it != end()){it = erase(it);}}void push_back(const T& x){insert(end(), x);}void push_front(const T& x){insert(begin(), x);}void pop_front(){erase(begin());}void pop_back(){erase(--end());}//void insert(iterator pos,const T& x)//{//	Node* cur = pos._node;//	Node* newnode = new Node(x);//	Node* prev = cur->_prev;//	//prev  newnode  cur//	prev->_next = newnode;//	newnode->_prev = prev;//	newnode->_next = cur;//	cur->_prev = newnode;//	//理论上可以认为list的迭代器不存在失效问题//}iterator insert(iterator pos, const T& x){Node* cur = pos._node;Node* newnode = new Node(x);Node* prev = cur->_prev;//prev  newnode  curprev->_next = newnode;newnode->_prev = prev;newnode->_next = cur;cur->_prev = newnode;++_size;return iterator(newnode);//指向新插入的元素}//void erase(iterator pos)//{//	Node* cur = pos._node;//	Node* prev = cur->_prev;//	Node* next = cur->_next;//	delete cur;//	prev->_next = next;//	next->_prev = prev;//}iterator erase(iterator pos){Node* cur = pos._node;Node* prev = cur->_prev;Node* next = cur->_next;delete cur;prev->_next = next;next->_prev = prev;--_size;//erase后的迭代器会失效,所有最好把返回值类型改为iteratorreturn iterator(next);}size_t size(){return _size;}private:Node* _head;size_t _size;};}

5.拷贝构造和赋值

namespace jxy
{template<class T>struct list_node{T _data;list_node<T>* _prev;list_node<T>* _next;list_node(const T& x = T()):_data(x),_prev(nullptr),_next(nullptr){}};template<class T>struct __list_iterator//一般前加__就说明这是内部的实现{typedef list_node<T> Node;typedef __list_iterator<T> self;Node* _node;__list_iterator(Node* node):_node(node){}self& operator++()//不是连续的物理空间,++不能到下一个位置{_node = _node->_next;return *this;}T& operator*(){return _node->_data;}bool operator!=(const self& s){return (_node != s._node);}};template<class T>class list//list的框架本质是封装+运算符重载{typedef list_node<T> Node;public:typedef __list_iterator<T> iterator;iterator begin(){//return iterator(_head->_next);return _head->_next;}iterator end(){//return iterator(_head);return _head;}void empty_init(){_head = new Node;_head->_next = _head;_head->_prev = _head;}list(){empty_init();}~list(){clear();delete(_head);_head = nullptr;}//拷贝构造//list(const list<T>& lt)//这里是const迭代器list(list<T>& lt){empty_init();for (auto e : lt){push_back(e);}}传统写法//list<int>& operator=(const list<int>& lt)//{//	if (this != &lt)//	{//		clear();//		for (auto e : lt)//		{//			push_back(e);//		}//	}//	return *this;//}void swap(list<int>& lt){std::swap(_head, lt._head);std::swap(_size, lt._size);}list<int>& operator=(list<int> lt)//调用拷贝构造{swap(lt);return *this;}private:Node* _head;size_t _size;};}

6.完善迭代器

namespace jxy
{template<class T>struct list_node{T _data;list_node<T>* _prev;list_node<T>* _next;list_node(const T& x = T()):_data(x),_prev(nullptr),_next(nullptr){}};template<class T>struct __list_iterator//一般前加__就说明这是内部的实现{typedef list_node<T> Node;typedef __list_iterator<T> self;Node* _node;__list_iterator(Node* node):_node(node){}self& operator++()//不是连续的物理空间,++不能到下一个位置{_node = _node->_next;return *this;}self& operator--(){_node = _node->_prev;return *this;}//自定义类型尽量使用前置++,后置++要返回++之前的值self operator++(int){self tmp(*this);_node = _node->_next;return tmp;}self operator--(int){self tmp(*this);_node = _node->_prev;return tmp;}T& operator*(){return _node->_data;}bool operator!=(const self& s){return (_node != s._node);}bool operator==(const self& s){return (_node == s._node);}//迭代器不需要析构函数//它虽然有结点的指针,但是指针是不属于它的,它不能释放//迭代器的拷贝构造和赋值也不需要去实现深拷贝};template<class T>class list{typedef list_node<T> Node;public:private:Node* _head;size_t _size;};}

7.补充:迭代器的->运算符重载

namespace jxy
{template<class T>struct list_node{T _data;list_node<T>* _prev;list_node<T>* _next;list_node(const T& x = T()):_data(x),_prev(nullptr),_next(nullptr){}};template<class T>struct __list_iterator//一般前加__就说明这是内部的实现{typedef list_node<T> Node;typedef __list_iterator<T> self;Node* _node;__list_iterator(Node* node):_node(node){}self& operator++()//不是连续的物理空间,++不能到下一个位置{_node = _node->_next;return *this;}T& operator*(){return _node->_data;}bool operator!=(const self& s){return (_node != s._node);}T* operator->(){return &_node->_data;}};template<class T>class list{typedef list_node<T> Node;public:private:Node* _head;size_t _size;};struct AA{AA(int a1 = 0, int a2 = 0):_a1(a1),_a2(a2){}int _a1;int _a2;};void test_list3(){//存一个自定义类型list<AA> lt;lt.push_back(AA(1, 2));lt.push_back(AA(2, 3));lt.push_back(AA(3, 4));list<AA>::iterator it = lt.begin();while (it != lt.end()){//cout << *it << " ";//*it的类型是AA,不支持流插入//一、让AA类支持流插入//二、打印公有成员变量//cout << (*it)._a1 << " " << (*it)._a2 << endl;//三、让AA类支持->//自定义类型不支持运算符,需要重载cout << it->_a1 << " " << it->_a2 << endl;cout << it.operator->()->_a1 << " " << it.operator->()->_a2 << endl;++it;//当数据存储自定义类型时,重载->}//解引用有三种方式:*、[]、->int* p = new int;*p = 1;AA* ptr = new AA;ptr->_a1=1;}}

8.const迭代器

namespace jxy
{template<class T>struct list_node{T _data;list_node<T>* _prev;list_node<T>* _next;list_node(const T& x = T()):_data(x),_prev(nullptr),_next(nullptr){}};//const迭代器模拟的是指向的内容不能改变,而不是本身不能改变//const迭代器本身可以++template<class T>struct __list_const_iterator//const迭代器是一个单独的类{typedef list_node<T> Node;typedef __list_const_iterator<T> self;Node* _node;__list_const_iterator(Node* node):_node(node){}self& operator++(){_node = _node->_next;return *this;}self& operator--(){_node = _node->_prev;return *this;}self operator++(int){self tmp(*this);_node = _node->_next;return tmp;}self operator--(int){self tmp(*this);_node = _node->_prev;return tmp;}const T& operator*() //通过解引用才能修改数据{return _node->_data;//返回的是const别名,不能修改}const T* operator->(){return &_node->_data;}bool operator!=(const self& s){return (_node != s._node);}bool operator==(const self& s){return (_node == s._node);}};template<class T>class list//list的框架本质是封装+运算符重载{typedef list_node<T> Node;public:typedef __list_iterator<T> iterator;typedef __list_const_iterator<T> const_iterator;//单独去支持一个类型:const_iteratorconst_iterator begin() const{//return const_iterator(_head->_next);return _head->_next;}const_iterator end() const{//return const_iterator(_head);return _head;}private:Node* _head;size_t _size;};//测试const迭代器void print_list(const list<int>& lt)
//容器通常不支持流插入,所以要写个print函数{list<int>::const_iterator it = lt.begin();while (it != lt.end()){//*it = 100;//不可修改cout << *it << " ";it++;}cout << endl;}void test_list4(){list<int> lt;lt.push_back(1);lt.push_back(2);lt.push_back(3);lt.push_back(4);lt.push_back(5);print_list(lt);}
}

9.改善为模板

当前代码的实现太过冗余,iterator类和const_iterator类的代码实现高度重合

namespace jxy
{template<class T>struct list_node{T _data;list_node<T>* _prev;list_node<T>* _next;list_node(const T& x = T()):_data(x)//这里是拷贝构造,_prev(nullptr),_next(nullptr){}};//T  T&  T*
//T  const T&  const T*
template<class T,class Ref,class Ptr>
struct __list_iterator
{typedef list_node<T> Node;typedef __list_iterator<T,Ref,Ptr> self;Node* _node;__list_iterator(Node* node):_node(node){}self& operator++()//不是连续的物理空间,++不能到下一个位置{_node = _node->_next;return *this;}self& operator--(){_node = _node->_prev;return *this;}self operator++(int){self tmp(*this);_node = _node->_next;return tmp;}self operator--(int){self tmp(*this);_node = _node->_prev;return tmp;}Ref operator*()//从泛型的角度来说,这里返回值类型是什么是不知道的{return _node->_data;}Ptr operator->(){return &_node->_data;}bool operator!=(const self& s){return (_node != s._node);}bool operator==(const self& s){return (_node == s._node);}//所以迭代器到底如何实现,是根据容器的底层结构来决定的
};template<class T>
class list//list的框架本质是封装+运算符重载
{typedef list_node<T> Node;public:typedef __list_iterator<T,T&,T*> iterator;typedef __list_iterator<T, const T&, const T*> const_iterator;const_iterator begin() const{//return const_iterator(_head->_next);return _head->_next;}const_iterator end() const{//return const_iterator(_head);return _head;}iterator begin(){//return iterator(_head->_next);return _head->_next;}iterator end(){//return iterator(_head);return _head;}void empty_init(){_head = new Node;_head->_next = _head;_head->_prev = _head;_size = 0;}list(){empty_init();}~list(){clear();delete(_head);_head = nullptr;}//拷贝构造list(const list<T>& lt)//这里是const迭代器{empty_init();for (auto e : lt){push_back(e);}}void swap(list<int>& lt){std::swap(_head, lt._head);std::swap(_size, lt._size);}list<int>& operator=(list<int> lt)//调用拷贝构造{swap(lt);return *this;}void clear()//不清哨兵位的头结点{iterator it = begin();while (it != end()){it = erase(it);}}void push_back(const T& x){insert(end(), x);}void push_front(const T& x){insert(begin(), x);}void pop_front(){erase(begin());}void pop_back(){erase(--end());}iterator insert(iterator pos, const T& x){Node* cur = pos._node;Node* newnode = new Node(x);Node* prev = cur->_prev;//prev  newnode  curprev->_next = newnode;newnode->_prev = prev;newnode->_next = cur;cur->_prev = newnode;++_size;return iterator(newnode);//指向新插入的元素}iterator erase(iterator pos){Node* cur = pos._node;Node* prev = cur->_prev;Node* next = cur->_next;delete cur;prev->_next = next;next->_prev = prev;--_size;//erase后的迭代器会失效,所有最好把返回值类型改为iteratorreturn iterator(next);}size_t size(){return _size;}private:Node* _head;size_t _size;
};//测试const迭代器void print_list(const list<int>& lt){list<int>::const_iterator it = lt.begin();while (it != lt.end()){//*it = 100;//不可修改cout << *it << " ";it++;}cout << endl;for (auto e : lt){cout << e << " ";}cout << endl;}void test_list4(){list<int> lt;lt.push_back(1);lt.push_back(2);lt.push_back(3);lt.push_back(4);lt.push_back(5);print_list(lt);}
}

10.关于typename

namespace jxy
{template<class T>struct list_node{T _data;list_node<T>* _prev;list_node<T>* _next;list_node(const T& x = T()):_data(x),_prev(nullptr),_next(nullptr){}};template<class T>void print_list(const list<T>& lt)//之前的print只支持int类型{list<T>::const_iterator it = lt.begin();while (it != lt.end()){cout << *it << " ";it++;}cout << endl;for (auto e : lt){cout << e << " ";}cout << endl;}void test_list4(){list<string> lt1;lt1.push_back("1111111111111111111111");lt1.push_back("1111111111111111111111");lt1.push_back("1111111111111111111111");lt1.push_back("1111111111111111111111");//这里会不会涉及深层次的深拷贝问题?//之前的vector容器就涉及到了深层次的浅拷贝问题//它的主要原因是因为扩容时使用了memcpy//list不存在扩容的事情,也就不涉及这个问题print_list(lt1);}
}

但事实上,这样修改以后是编译不通过的。

 

这就涉及到另一个知识点,在日常使用中,模板命名时,使用class和使用typename是等价的

template<class T>	
template<typename T>

但此时的场景下,就要使用typename了。

namespace jxy
{template<class T>struct list_node{T _data;list_node<T>* _prev;list_node<T>* _next;list_node(const T& x = T()):_data(x),_prev(nullptr),_next(nullptr){}};template<typename T>void print_list(const list<T>& lt)//之前的print只支持int类型{typename list<T>::const_iterator it = lt.begin();while (it != lt.end()){cout << *it << " ";it++;}cout << endl;for (auto e : lt){cout << e << " ";}cout << endl;}void test_list4(){list<string> lt1;lt1.push_back("1111111111111111111111");lt1.push_back("1111111111111111111111");lt1.push_back("1111111111111111111111");lt1.push_back("1111111111111111111111");print_list(lt1);}
}
typename list<T>::const_iterator it = lt.begin();
当模板是未实例化的类模板时,如list<T>
编译器不能去它里面查找,它里面带有许多不可确定的东西
编译器在编译阶段、没有实例化时,只会对这里进行初步的检查
所以编译器无法判断list<T>::const_iterator是内嵌类型,还是静态成员变量
所以这里要加上typename,凡是这种类模板中取类型都要加
前面加一个typename就是告诉编译器,这里是一个类型
要等list<T>实例化了,再去类里面去取
模板里面取东西都要加typename,使得编译器初步检查时先通过
然后实例化后,再去类中取这个类型,就知道它具体是什么了

11.再次改善为模板

namespace jxy
{template<class T>struct list_node{T _data;list_node<T>* _prev;list_node<T>* _next;list_node(const T& x = T()):_data(x),_prev(nullptr),_next(nullptr){}};template<typename T>void print_list(const list<T>& lt){typename list<T>::const_iterator it = lt.begin();while (it != lt.end()){cout << *it << " ";it++;}cout << endl;for (auto e : lt){cout << e << " ";}cout << endl;}void test_list4(){list<string> lt1;lt1.push_back("1111111111111111111111");lt1.push_back("1111111111111111111111");lt1.push_back("1111111111111111111111");lt1.push_back("1111111111111111111111");print_list(lt1);vector<string> v;v.push_back("111111111111");v.push_back("111111111111");v.push_back("111111111111");v.push_back("111111111111");v.push_back("111111111111");print_list(v);//此时是打印不了的}
}

print_list是专门打印list的,想要打印vector,难道再去写一个逻辑高度重复的print函数吗?

namespace jxy
{template<class T>struct list_node{T _data;list_node<T>* _prev;list_node<T>* _next;list_node(const T& x = T()):_data(x),_prev(nullptr),_next(nullptr){}};template<typename Container>void print_container(const Container& con)//针对容器的打印{typename Container::const_iterator it = con.begin();while (it != con.end()){cout << *it << " ";it++;}cout << endl;}//模板实现了泛型编程,本质就是本来应该由我们做的事情交给了编译器void test_list4(){list<int> lt;lt.push_back(1);lt.push_back(2);lt.push_back(3);lt.push_back(4);lt.push_back(5);print_container(lt);list<string> lt1;lt1.push_back("1111111111111111111111");lt1.push_back("1111111111111111111111");lt1.push_back("1111111111111111111111");lt1.push_back("1111111111111111111111");print_container(lt1);vector<string> v;v.push_back("111111111111");v.push_back("111111111111");v.push_back("111111111111");v.push_back("111111111111");v.push_back("111111111111");print_container(v);}
}

12.总结:对比vector和list

vector与list都是STL中非常重要的序列式容器,由于两个容器的底层结构不同,导致其特性以及应用场景不同
vectorlist
底层结构
动态顺序表,一段连续空间
带头结点的双向循环链表
随机访问
支持随机访问,访问某个元素效率O(1),适合sort数据
不支持随机访问,访问某个元素效率O(N)
插入和删除
任意位置插入和删除效率低,需要搬移元素,时间复杂度为O(N),插入时有可能需要增容,增容:开辟新空间,拷贝元素,释放旧空间,导致效率更低
任意位置插入和删除效率高,不需要搬移元素,时间复杂度为O(1)
空间利用率
底层为连续空间,不容易造成内存碎片,空间利用率高,CPU高速缓存利用率高
底层节点动态开辟,小节点容易造成内存碎片,空间利用率低,缓存利用率低
迭代器原生态指针
对原生态指针(节点指针)进行封装
迭代器失效
在插入元素时,要给所有的迭代器重新赋值,因为插入元素有可能会导致重新扩容,致使原来迭代器失效,删除时,当前迭代器需要重新赋值否则会失效
插入元素不会导致迭代器失效,删除元素时,只会导致当前迭代器失效,其他迭代器不受影响
使用场景
需要高效存储,支持随机访问,不关心插入删除效率
大量插入和删除操作,不关心随
机访问

相关文章:

C++——模拟实现list

1.初步实现结点和链表 namespace jxy {template<class T>struct list_node{T _data;list_node<T>* _prev;list_node<T>* _next;list_node(const T& x T()):_data(x),_prev(nullptr),_next(nullptr){}};template<class T>class list//list的框架本…...

React中useState、useReducer与useRef

useState 详解 useState 是 React 函数组件中用于管理组件状态的 Hook。它提供了一种简洁的方式来在函数组件中添加状态&#xff0c;并在状态改变时触发组件重新渲染。以下是 useState 的详细解析&#xff1a; 一、基本概念 useState 是一个函数&#xff0c;它接收一个初始状…...

ReGCL Rethinking Message Passingin Graph Contrastive Learning

AAAI24 推荐指数&#xff1a; #paper/⭐ 总体说&#xff1a;利用梯度对对比正负样本加权的。个人觉得和与正负样本加权没有区别&#xff0c;读完之后不想做笔记了。...

ubutun安装ffmpeg

安装依赖 sudo apt-get install yasm sudo apt-get install libsdl1.2-dev sudo apt-get install libsdl2-dev 下载安装 tar -zxvf filename.gz ./configure --enable-shared --prefix/usr/local/ffmpeg make -j4 sudo make install 添加路径 路径/usr/local/ffmpeg…...

Vue的基本用法及模板语法

Vue.js使用了基于 HTML 的模板语法&#xff0c;允许开发者声明式地将 DOM 绑定至底层 Vue实例的数据。所有 Vue.js的模板都是合法的 HTML&#xff0c;所以能被遵循规范的浏览器和 HTML 解析器解析。 在底层的实现上&#xff0c;Vue将模板编译成虚拟 DOM 渲染函数。结合响应系…...

Redis数据库与GO完结篇:redis操作总结与GO使用redis

一、redis操作总结 由于写redis命令的时候有提示符&#xff0c;所以下表只给出命令名称 数据类型操作简介字符串GET, SET, MGET, MSET, SETEX,DEL最基本的数据类型&#xff0c;存储任意二进制数据&#xff0c;支持简单操作和原子计数。适合存储重复数据。哈希HSET, HGET, HDE…...

《重生到现代之从零开始的C语言生活》—— 动态内存管理

动态内存分配 我们在开辟内存的时候就是 int a 3;这样 但是这样开的空间大小是固定的&#xff0c;且大小不能调整 但是如果我们用动态内存开辟的话&#xff0c;就可以自己申请和释放空间、 malloc 是C语言提供的一个开辟动态空间的函数 void* malloc (size_t size);//si…...

四、Spring Boot集成Spring Security之登录登出业务逻辑

Spring Boot集成Spring Security之登录登出业务逻辑 一、概要说明二、基于内存的用户名密码1、默认用户名密码2、自定义用户名密码3、为方便测试添加测试接口TestController 三、登录登出重要概念介绍四、登录业务逻辑1、登录业务相关过滤器2、访问业务请求处理流程①、访问业务…...

pipe和pipefd

Linux 中 pipe 的详细介绍 在 Linux 中&#xff0c;pipe 是一个系统调用&#xff0c;用于创建一个管道&#xff0c;这是一种用于进程间通信&#xff08;IPC&#xff09;的机制。管道允许两个进程之间进行单向数据传输&#xff0c;通常是一个进程向管道写入数据&#xff0c;而另…...

无人机之飞控仿真技术篇

一、无人机飞控仿真技术的定义 无人机飞控仿真技术主要是指飞行控制系统仿真&#xff0c;它是以无人机的运动情况为研究对象&#xff0c;面向对象的复杂系统仿真。通过该技术&#xff0c;可以模拟无人机的飞行过程&#xff0c;评估飞行控制系统的性能&#xff0c;优化飞行参数&…...

Tetra Pak利乐触摸屏维修beijer北尔触摸屏维修E1151

TetraPak利乐包装机触摸显示屏维修&#xff0c;北尔全系列型号触摸屏修理 维修注意事项&#xff1a; 上电前&#xff0c;应检查负载是否接上或是否正确&#xff1b; 测量电压时&#xff0c;确认档位是否在电压档。要确认仪器仪表的量程应大于测试点的电压&#xff1b; 更换电…...

Python_网络编程(IP 端口 协议)

网络编程&#xff1a; 互联网时代&#xff0c;现在基本上所有的程序都是网络程序&#xff0c;很少有单机版的程序了。网络编程就是如何在程序中实现两台计算机的通信。Python语言中&#xff0c;提供了大量的内置模块和第三方模块用于支持各种网络访问&#xff0c;而且Python语言…...

Adobe Acrobat提示“3D数据解析错误”

原因&#xff1a;在使用Adobe Acrobat打开3D PDF时&#xff0c;因当前Adobe Acrobat的配置存在错误&#xff0c;所以无法打开 解决方法&#xff1a;重新生成配置 首先到达下面的路径C:\Users\你的用户名\AppData\Local\Adobe\Acrobat 下面为我的路径内容 若该路径下存在文件…...

红帽7—Mysql路由部署

MySQL Router 是一个对应用程序透明的InnoDB Cluster连接路由服务&#xff0c;提供负载均衡、应用连接故障转移和客户端路 由。 利用路由器的连接路由特性&#xff0c;用户可以编写应用程序来连接到路由器&#xff0c;并令路由器使用相应的路由策略 来处理连接&#xff0c;使其…...

LLM4Rec最新工作: 字节发布用于序列推荐的分层大模型HLLM

前几个月 Meta HSTU 点燃各大厂商对 LLM4Rec 的热情&#xff0c;一时间&#xff0c;探索推荐领域的 Scaling Law、实现推荐的 ChatGPT 时刻、取代传统推荐模型等一系列话题让人兴奋&#xff0c;然而理想有多丰满&#xff0c;现实就有多骨感&#xff0c;尚未有业界公开真正复刻 …...

怎么高效对接SaaS平台数据?

SaaS平台数据对接是指将一个或多个SaaS平台中的数据集成到其他应用或平台中的过程。在当前的数字化时代&#xff0c;企业越来越倾向于使用SaaS平台来管理他们的业务和数据。然而&#xff0c;这些数据通常散布在不同的SaaS平台中&#xff0c;这对于企业数据的整合和分析来说可能…...

Spark算子使用-Map,FlatMap,Filter,diatinct,groupBy,sortBy

目录 Map算子使用 FlatMap算子使用 Filter算子使用-数据过滤 Distinct算子使用-数据去重 groupBy算子使用-数据分组 sortBy算子使用-数据排序 Map算子使用 # map算子主要使用长场景&#xff0c;一个转化rdd中每个元素的数据类型&#xff0c;拼接rdd中的元素数据&#xf…...

CSS响应式布局

CSS 响应式布局也称自适应布局&#xff0c;是 Ethan Marcotte 在 2010 年 5 月份提出的一个概念&#xff0c;简单来讲就是一个网站能够兼容多个不同的终端&#xff08;设备&#xff09;&#xff0c;而不是为每个终端做一个特定的版本。这个概念是为解决移动端浏览网页而诞生的。…...

AI大模型书籍丨掌握 LLM 和 RAG 技术,这本大模型小鸟书值得一看!

本指南旨在帮助数据科学家、机器学习工程师和机器学习/AI 架构师探索信息检索与 LLMs 的集成及其相互增强。特别聚焦于 LLM 和检索增强生成&#xff08;RAG&#xff09;技术在信息检索中的应用&#xff0c;通过引入外部数据库与 LLMs 的结合&#xff0c;提高检索系统的性能。 …...

Mysql和Oracle使用差异和主观感受

这两种常用的关系型数据库有何差异&#xff1f; 支持和社区 MySQL&#xff1a;有一个活跃的开源社区&#xff0c;用户可以获取大量的文档和支持。 Oracle&#xff1a;提供了专业的技术支持&#xff0c;但通常需要额外的费用。 易用性 MySQL&#xff1a;通常被认为是更易于学…...

Vue记事本应用实现教程

文章目录 1. 项目介绍2. 开发环境准备3. 设计应用界面4. 创建Vue实例和数据模型5. 实现记事本功能5.1 添加新记事项5.2 删除记事项5.3 清空所有记事 6. 添加样式7. 功能扩展&#xff1a;显示创建时间8. 功能扩展&#xff1a;记事项搜索9. 完整代码10. Vue知识点解析10.1 数据绑…...

JavaScript 中的 ES|QL:利用 Apache Arrow 工具

作者&#xff1a;来自 Elastic Jeffrey Rengifo 学习如何将 ES|QL 与 JavaScript 的 Apache Arrow 客户端工具一起使用。 想获得 Elastic 认证吗&#xff1f;了解下一期 Elasticsearch Engineer 培训的时间吧&#xff01; Elasticsearch 拥有众多新功能&#xff0c;助你为自己…...

IGP(Interior Gateway Protocol,内部网关协议)

IGP&#xff08;Interior Gateway Protocol&#xff0c;内部网关协议&#xff09; 是一种用于在一个自治系统&#xff08;AS&#xff09;内部传递路由信息的路由协议&#xff0c;主要用于在一个组织或机构的内部网络中决定数据包的最佳路径。与用于自治系统之间通信的 EGP&…...

解决Ubuntu22.04 VMware失败的问题 ubuntu入门之二十八

现象1 打开VMware失败 Ubuntu升级之后打开VMware上报需要安装vmmon和vmnet&#xff0c;点击确认后如下提示 最终上报fail 解决方法 内核升级导致&#xff0c;需要在新内核下重新下载编译安装 查看版本 $ vmware -v VMware Workstation 17.5.1 build-23298084$ lsb_release…...

STM32F4基本定时器使用和原理详解

STM32F4基本定时器使用和原理详解 前言如何确定定时器挂载在哪条时钟线上配置及使用方法参数配置PrescalerCounter ModeCounter Periodauto-reload preloadTrigger Event Selection 中断配置生成的代码及使用方法初始化代码基本定时器触发DCA或者ADC的代码讲解中断代码定时启动…...

NFT模式:数字资产确权与链游经济系统构建

NFT模式&#xff1a;数字资产确权与链游经济系统构建 ——从技术架构到可持续生态的范式革命 一、确权技术革新&#xff1a;构建可信数字资产基石 1. 区块链底层架构的进化 跨链互操作协议&#xff1a;基于LayerZero协议实现以太坊、Solana等公链资产互通&#xff0c;通过零知…...

GC1808高性能24位立体声音频ADC芯片解析

1. 芯片概述 GC1808是一款24位立体声音频模数转换器&#xff08;ADC&#xff09;&#xff0c;支持8kHz~96kHz采样率&#xff0c;集成Δ-Σ调制器、数字抗混叠滤波器和高通滤波器&#xff0c;适用于高保真音频采集场景。 2. 核心特性 高精度&#xff1a;24位分辨率&#xff0c…...

C++使用 new 来创建动态数组

问题&#xff1a; 不能使用变量定义数组大小 原因&#xff1a; 这是因为数组在内存中是连续存储的&#xff0c;编译器需要在编译阶段就确定数组的大小&#xff0c;以便正确地分配内存空间。如果允许使用变量来定义数组的大小&#xff0c;那么编译器就无法在编译时确定数组的大…...

算法岗面试经验分享-大模型篇

文章目录 A 基础语言模型A.1 TransformerA.2 Bert B 大语言模型结构B.1 GPTB.2 LLamaB.3 ChatGLMB.4 Qwen C 大语言模型微调C.1 Fine-tuningC.2 Adapter-tuningC.3 Prefix-tuningC.4 P-tuningC.5 LoRA A 基础语言模型 A.1 Transformer &#xff08;1&#xff09;资源 论文&a…...

处理vxe-table 表尾数据是单独一个接口,表格tableData数据更新后,需要点击两下,表尾才是正确的

修改bug思路&#xff1a; 分别把 tabledata 和 表尾相关数据 console.log() 发现 更新数据先后顺序不对 settimeout延迟查询表格接口 ——测试可行 升级↑&#xff1a;async await 等接口返回后再开始下一个接口查询 ________________________________________________________…...