C++ stl容器list的底层模拟实现

news/2024/5/21 13:53:34

目录

前言:

1.创建节点

2.普通迭代器的封装

3.反向迭代器的封装

为什么要对正向迭代器进行封装?

4.const迭代器

5.构造函数

6.拷贝构造

7.赋值重载

8.insert

9.erase

10.析构

11.头插头删,尾插尾删

12.完整代码+简单测试

总结:


前言:

模拟实现list,本篇的重点就是由于list是一个双向循环链表结构,所以我们对迭代器的实现不能是简单的指针的++,--了,因为我们知道,链表的存储不一定是连续的,所以直接++,--是链接不起来节点的,所以我们要对迭代器也就是对节点的指针进行封装。结尾会附上完整的代码。

1.创建节点

	template<class T>struct list_node{list_node<T>* _prev;list_node<T>* _next;T _data;list_node(const T& x= T())//这里不给缺省值可能会因为没有默认构造函数而编不过:_prev(nullptr),_next(nullptr),_data(x){}};

注意给缺省值,这样全缺省就会被当做默认构造了,不会因为没有默认构造而报错。

我们实现的list是带哨兵位的,它同时是迭代器的end()(因为是双向循环的list)。

 

2.普通迭代器的封装

	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迭代器是不能直接++的_list_iterator(node* n):_node(n){}Ref operator*()//返回的必须是引用,不然改变不了外面的对象的成员,要支持对自己解引用改变值就要用应用{return _node->_data;}Ptr operator->(){return &(_node->_data);//返回地址,再解引用直接访问数据}self& operator++(){_node = _node->_next;return *this;}self operator++(int){self tmp(*this);//默认的拷贝构造可以,因为没有深拷贝_node = _node->_next;return tmp;}self& operator--(){_node = _node->_prev;return *this;}self operator--(int){self tmp(*this);_node = _node->_prev;return tmp;}bool operator!=(const self& s){return _node != s._node;}bool operator==(const self& s){return _node == s._node;}};

注意list是双向迭代器,可以++,--,不能+,-

这里对迭代器的实现就如我们开始所说的, 迭代器的实现就是使用节点的指针实现的,而我们不能直接对list创建出的节点进行++,--,所以要进行一层封装;然后再对节点指针初始化。

重载解引用时要注意返回的是引用,不然对自己解引用的时候,返回值如果是临时的,是改变不了内部的data的。

对于箭头的解引用,是为了支持这样的场景:

struct AA{int _a1;int _a2;AA(int a1=0,int a2=0):_a1(a1),_a2(a2){}};void test_list2(){list<AA> lt;lt.push_back(AA(1,1));lt.push_back(AA(2, 2));lt.push_back(AA(3, 3));list<AA>::iterator it = lt.begin();while (it != lt.end()){//cout << (*it)._a1 << " "<<(*it)._a2<<endl;cout << it->_a1 << " " << it->_a2 << endl;//面对这样的类型,需要重载->,.也可以访问,但是有点别扭++it;}cout << endl;}

迭代器遇到箭头,返回对象的地址也就是节点数据的地址,再解引用找到成员。或者说node中的data就是存放的是对象(也就是用来初始化的数据),然后重载的->拿到对象的地址,再->去访问里面的成员变量_a1。

对于前置后置++与--,前置就返回对象的引用,是传引用返回;后置需要进行拷贝给一个临时的对象,再对调用对象++--,返回的是tmp也就是没有改变的对象,是传值返回。注意区分前置后置,后置要加上参数int。

3.反向迭代器的封装

namespace my_iterator
{template<class Iterator,class Ref,class Ptr>struct ReverseIterator{typedef ReverseIterator<Iterator,Ref,Ptr> self;Iterator _cur;ReverseIterator(Iterator it):_cur(it){}Ref operator*(){Iterator tmp = _cur;//因为要--,而解引用是不能改值的,所以用tmp改并返回--tmp;return *tmp;}Ptr operator->(){return &operator*();//&this->operator*()}self operator++(){--_cur;//直接的++--就能直接改了,所以可以直接返回原对象,--(this->_cur)return *this;}self operator--(){++_cur;return *this;}bool operator!=(const self& s){return _cur != s._cur;}};
}

第一个模版参数就是任意类型的迭代器区间,因为我们实现反向迭代器需要现有正向迭代器。

一样的不能直接++--,所以进行一层封装,此时_cur就指向传的迭代器的位置。

对解引用的重载一样是要返回引用,不然返回的是一个临时的变量对自己解引用就没用了,也只有返回的是引用才能修改。例如我们要传的是begin(),那反向迭代器就应该从哨兵位开始,所以要先对传过来的迭代器进行--。

箭头就是返回当前位置迭代器的地址,所以是直接复用上面的。

++--与正向的迭代器相反,而_cur的类型就是传过来的迭代器类型,++--会调用传过来迭代器类型的重载。

 

为什么要对正向迭代器进行封装?

4.const迭代器

	typedef list_node<T> node;
public:typedef _list_iterator<T, T&, T*> iterator;typedef _list_iterator<T, const T&, const T*> const_iterator;typedef ReverseIterator<iterator,T&,T*> reverse_iterator;typedef ReverseIterator<iterator, const T&, const T*> const_reverse_iterator;const_iterator begin() const//本身const迭代器是让迭代器指向的内容不能修改,但是这样用const修饰迭代器本身也不能修改了{return const_iterator(_head->_next);}const_iterator end() const{return const_iterator(_head);}

 提供const版本,供const修饰的对象调用,防止权限的放大。

那为什么提供完const版本了,const版本已经可以供普通迭代器与const迭代器使用,还单独提出来这个版本?和因为const迭代器还需要迭代器也就是节点指针指向的内容不能修改。例如it是const类型迭代器的对象,*it就可以,++it也可以,但是(*it)++就不可以。

5.构造函数

		void empty_Init(){_head = new node;_head->_next = _head;_head->_prev = _head;}list(){empty_Init();}template<class Iterator>list(Iterator first, Iterator end){empty_Init();//别忘加上哨兵位,没有哨兵位识别不了endwhile (first != end){push_back(*first);first++;//这里的++first会调用重载的,因为传过来的是一个迭代器}}

哨兵位是空的,不放数据,但是哨兵位是正向迭代器的end,要加上。

默认无参构造就只有哨兵位,提供的迭代器的构造也要有哨兵位。

first++不用担心,first是迭代器类型的,所以会调用迭代器的++。 

6.拷贝构造

		//传统的拷贝构造//list(const list<T>& lt)//{//	empty_Init();//	for (auto e : lt)//	{//		push_back(e);//this->push_back(e)//	}//}void swap(list<T>& tmp)//要使用库中的swap,而库中的swap就不带const;况且交换的是头节点,const修饰的就不能修改指向{std::swap(_head, tmp._head);}//现代的拷贝构造list(const list<T>& lt){empty_Init();list<T> tmp(lt.begin(), lt.end());//为什么还要多一个变量,因为下面swap的参数没有const,而拷贝构造要加constswap(tmp);//this->swap(tmp)}

拷贝构造,直接使用库中的swap,交换头节点也就是哨兵位的指向就行,因为链表后面的关系都通过头节点找到,所以也就相当于都交换了。

注意库中swap的参数:

 

7.赋值重载

		list<T>& operator=(list<T> lt)//参数不能使用引用,使用引用再使用swap交换,原来赋值的值就被改了{swap(lt);return *this;}

一样是使用库中的swap,但是赋值的参数不能是引用,例如L1=L3,用引用再加上使用swap交换头节点的指向,L3就被改了,我们要求的是赋值是不能改变赋过来的对象的,内置类型也是(a=b)。 

 

8.insert

		void insert(iterator pos,const T& x){node* cur = pos._node;node* prev = cur->_prev;node* newnode = new node(x);prev->_next = newnode;newnode->_prev = prev;newnode->_next = cur;cur->_prev = newnode;}

链接节点即可,注意插入的值可能是任意类型,所以要用模版参数并且带上const与引用,防止是内置类型的值是const,传过来权限放大。

插入pos位置,也就是在pos前和pos位置之间插入。 

 

9.erase

		iterator erase(iterator pos){assert(pos != end());node* cur = pos._node;node* prev = cur->_prev;node* next = cur->_next;prev->_next = next;next->_prev = prev;delete pos._node;return iterator(next);}

注意删除完返回删除数据的下一个迭代器位置。

删除就是找前找后,删除节点,链接前后。

_node是new出来的,注意配套使用。

 

10.析构

void clear()
{iterator it = begin();while (it != end()){it= erase(it);//删除后返回的是下一个数据的位置,所以循环就走起来了}
}~list()
{clear();delete _head;_head = nullptr;
}

注意迭代器的erase删除后返回的是删除数据的下一个迭代器位置,所以用it接收就不怕迭代器失效了,同时循环也走起来了。 

11.头插头删,尾插尾删

		void push_back(const T& x){/*node* tail = _head->_prev;node* newnode = new node(x);tail->_next = newnode;newnode->_prev = tail;_head->_prev = newnode;newnode->_next = _head;*/insert(end(), x);}void push_front(const T& x){insert(begin(),x);}void pop_back(){erase(--end());}void pop_front(){erase(begin());}

直接复用即可。 

12.完整代码+简单测试

封装的反向迭代器: 

#pragma oncenamespace my_iterator
{template<class Iterator,class Ref,class Ptr>struct ReverseIterator{typedef ReverseIterator<Iterator,Ref,Ptr> self;Iterator _cur;ReverseIterator(Iterator it):_cur(it){}Ref operator*(){Iterator tmp = _cur;//因为要--,而解引用是不能改值的,所以用tmp改并返回--tmp;return *tmp;}Ptr operator->(){return &operator*();}self operator++(){--_cur;//直接的++--就能直接改了,所以可以直接返回原对象return *this;}self operator--(){++_cur;return *this;}bool operator!=(const self& s){return _cur != s._cur;}};
}
#pragma once
#include "my_iterator.h"#include <iostream>
#include <assert.h>
#include <list>using namespace my_iterator;
using namespace std;namespace my_list
{template<class T>struct list_node{list_node<T>* _prev;list_node<T>* _next;T _data;list_node(const T& x= T())//这里不给缺省值可能会因为没有默认构造函数而编不过:_prev(nullptr),_next(nullptr),_data(x){}};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迭代器是不能直接++的_list_iterator(node* n):_node(n){}Ref operator*()//返回的必须是引用,不然改变不了外面的对象的成员,要支持对自己解引用改变值就要用应用{return _node->_data;}Ptr operator->(){return &(_node->_data);//返回地址,再解引用直接访问数据}self& operator++(){_node = _node->_next;return *this;}self operator++(int){self tmp(*this);//默认的拷贝构造可以,因为没有深拷贝_node = _node->_next;return tmp;}self& operator--(){_node = _node->_prev;return *this;}self operator--(int){self tmp(*this);_node = _node->_prev;return tmp;}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:typedef _list_iterator<T, T&, T*> iterator;typedef _list_iterator<T, const T&, const T*> const_iterator;typedef ReverseIterator<iterator,T&,T*> reverse_iterator;typedef ReverseIterator<iterator, const T&, const T*> const_reverse_iterator;void empty_Init(){_head = new node;_head->_next = _head;_head->_prev = _head;}list(){empty_Init();}template<class Iterator>list(Iterator first, Iterator end){empty_Init();//别忘加上哨兵位,没有哨兵位识别不了endwhile (first != end){push_back(*first);first++;//这里的++first会调用重载的,因为传过来的是一个迭代器}}//传统的拷贝构造//list(const list<T>& lt)//{//	empty_Init();//	for (auto e : lt)//	{//		push_back(e);//this->push_back//	}//}void swap(list<T>& tmp)//要使用库中的swap,而库中的swap就不带const;况且交换的是头节点,const修饰的就不能修改指向{std::swap(_head, tmp._head);}//现代的拷贝构造list(const list<T>& lt){empty_Init();list<T> tmp(lt.begin(), lt.end());//为什么还要多一个变量,因为下面swap的参数没有const,而拷贝构造要加constswap(tmp);//this->swap(tmp)}list<T>& operator=(list<T> lt)//参数不能使用引用,使用引用再使用swap交换,原来赋值的值就被改了{swap(lt);return *this;}void clear(){iterator it = begin();while (it != end()){it= erase(it);//删除后返回的是下一个数据的位置,所以循环就走起来了}}~list(){clear();delete _head;_head = nullptr;}iterator begin(){return iterator(_head->_next);}iterator end(){return iterator(_head);//哨兵位就是end}const_iterator begin() const//本身const迭代器是让迭代器指向的内容不能修改,但是这样用const修饰迭代器本身也不能修改了{return const_iterator(_head->_next);}const_iterator end() const{return const_iterator(_head);}reverse_iterator rbegin(){return reverse_iterator(end());}reverse_iterator rend(){return reverse_iterator(begin());}void push_back(const T& x){/*node* tail = _head->_prev;node* newnode = new node(x);tail->_next = newnode;newnode->_prev = tail;_head->_prev = newnode;newnode->_next = _head;*/insert(end(), x);}void push_front(const T& x){insert(begin(),x);}void pop_back(){erase(--end());}void pop_front(){erase(begin());}void insert(iterator pos,const T& x){node* cur = pos._node;node* prev = cur->_prev;node* newnode = new node(x);prev->_next = newnode;newnode->_prev = prev;newnode->_next = cur;cur->_prev = newnode;}iterator erase(iterator pos){assert(pos != end());node* cur = pos._node;node* prev = cur->_prev;node* next = cur->_next;prev->_next = next;next->_prev = prev;delete pos._node;return iterator(next);}private:node* _head;};void print_list(const list<int>& lt){list<int>::const_iterator it = lt.begin();//不能直接这样写,传递过来的this指针也是const list<int>*,权限放大了,要提供const版本while (it != lt.end()){cout << *it << " ";++it;}cout << endl;}void test_list1(){list<int> lt;lt.push_back(1);lt.push_back(2);lt.push_back(3);lt.push_back(4);list<int>::iterator it = lt.begin();//=调用默认的拷贝构造,是浅拷贝,但是可以,让it也指向begin的位置while (it != lt.end()){cout << *it << " ";++it;}cout << endl;for (auto e : lt){cout << e << " ";}cout << endl;print_list(lt);}struct AA{int _a1;int _a2;AA(int a1 = 0, int a2 = 0):_a1(a1), _a2(a2){}};void test_list2(){list<AA> lt;lt.push_back(AA(1, 1));lt.push_back(AA(2, 2));lt.push_back(AA(3, 3));list<AA>::iterator it = lt.begin();while (it != lt.end()){//cout << (*it)._a1 << " "<<(*it)._a2<<endl;cout << it->_a1 << " " << it->_a2 << endl;//面对这样的类型,需要重载->,.也可以访问,但是有点别扭++it;}cout << endl;}void test_list3(){list<int> lt;lt.push_back(1);lt.push_back(2);lt.push_back(3);lt.push_back(4);auto pos = lt.begin();++pos;lt.insert(pos, 20);for (auto e : lt){cout << e << " ";}cout << endl;lt.push_back(100);lt.push_front(1000);for (auto e : lt){cout << e << " ";}cout << endl;lt.pop_back();lt.pop_front();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);for (auto e : lt){cout << e << " ";}cout << endl;lt.clear();for (auto e : lt){cout << e << " ";}cout << endl;lt.push_back(1);lt.push_back(2);lt.push_back(3);lt.push_back(40);for (auto e : lt){cout << e << " ";}cout << endl;}void test_list5(){list<int> lt;lt.push_back(1);lt.push_back(2);lt.push_back(3);lt.push_back(4);for (auto e : lt){cout << e << " ";}cout << endl;list<int> lt2(lt);for (auto e : lt2){cout << e << " ";}cout << endl;list<int> lt3;lt3.push_back(10);lt3.push_back(20);lt3.push_back(30);for (auto e : lt3){cout << e << " ";}cout << endl;lt2 = lt3;for (auto e : lt2){cout << e << " ";}cout << endl;}void test_list6(){list<int> lt;lt.push_back(1);lt.push_back(2);lt.push_back(3);lt.push_back(4);list<int>::iterator it = lt.begin();//=调用默认的拷贝构造,是浅拷贝,但是可以,让it也指向begin的位置while (it != lt.end()){(*it) *= 2;cout << *it << " ";++it;}cout << endl;list<int>::reverse_iterator rit = lt.rbegin();while (rit != lt.rend()){cout << *rit << " ";++rit;}cout << endl;/*for (auto e : lt){cout << e << " ";}cout << endl;print_list(lt);*/}}

总结:

重点在迭代器与反向迭代器的的封装,其它的内容与其它的容器大致相同。


http://www.mrgr.cn/p/34376522

相关文章

Day104:漏洞发现-漏扫项目篇武装BURP浏览器插件信息收集分析辅助遥遥领先

目录 插件类-武装BurpSuite-漏洞检测&分析辅助 1、如何加载插件&#xff1a; 2、漏洞检测类&#xff1a; Fiora TsojanScan RouteVulScan APIKit 3、分析辅助类&#xff1a; 插件类-武装谷歌浏览器-信息收集&情报辅助 HackBar Heimdallr Wappalyzer FindS…

学会解压

1,自我疗愈 压力日志拒绝精神内耗

JavaSE图书管理系统实战

代码仓库地址&#xff1a;Java图书管理系统 1.前言 该项目将JavaSE的封装继承多态三大特性&#xff0c;使用了大量面向对象的操作&#xff0c;有利于巩固理解 &#xff08;1&#xff09;实现效果 2.实现步骤 第一步先把框架搭建起来&#xff0c;即创建出人&#xff1a;管理员和…

Java 集合(ArrayList、LinkedList、HashMap、HashSet、LinkedHashMap、LinkedHashSet)【补充复习】

Java 集合&#xff08;ArrayList、LinkedList、HashMap、HashSet、LinkedHashMap、LinkedHashSet&#xff09;【补充复习】 Java 集合概述Collection 接口继承树Map 接口继承树 Collection 接口方法使用 iterator 接口遍历集合元素使用 forearch 遍历集合元素 List 接口List 实…

git 拉取或者推送代码报错问题解决

报错截图:当推送远程时,提示无法访问github地址 原因:在拉取或者是提交项目时,会发生git的http和https代理,我们电脑本地已经存在SSL协议的协议,可以取消http和https代理 在git中运行: git config --global --unset http.proxy git config --global --unset https.proxy…

【VUE】使用Vue和CSS动画创建滚动列表

使用Vue和CSS动画创建滚动列表 在这篇文章中&#xff0c;我们将探讨如何使用Vue.js和CSS动画创建一个动态且视觉上吸引人的滚动列表。这个列表将自动滚动显示项目&#xff0c;类似于轮播图的方式&#xff0c;非常适合用于仪表盘、排行榜或任何需要在有限空间内展示项目列表的应…

【MYSQL锁】透彻地理解MYSQL锁

&#x1f525;作者主页&#xff1a;小林同学的学习笔录 &#x1f525;mysql专栏&#xff1a;小林同学的专栏 目录 1.锁 1.1 概述 1.2 全局锁 1.2.1 语法 1.2.1.1 加全局锁 1.2.1.2 数据备份 1.2.1.3 释放锁 1.2.1.4 特点 1.2.1.5 演示 1.3 表级锁 1.3.1 介绍 …

paddleocr图片文本识别

1. paddleocr  PaddleOCR 是一个基于 PaddlePaddle 深度学习框架的开源 OCR(Optical Character Recognition,光学字符识别)工具。它提供了一系列的预训练模型和工具,可以用于文本检测、文本识别和文本方向检测等任务。 提供了易于使用的 Python API,可以轻松地在你的项目…

Docker入门实战教程

文章目录 Docker引擎的安装Docker比vm虚拟机快 Docker常用命令帮助启动类命令镜像命令docker imagesdocker searchdocker pulldocker system dfdocker rmi 容器命令redis前台交互式启动redis后台守护式启动Nginx容器运行ubuntu交互式运行tomcat交互式运行对外暴露访问端口 Dock…

HarmonyOS NEXT应用开发之图片缩放效果实现

介绍 图片预览在应用开发中是一种常见场景,在诸如QQ、微信、微博等应用中均被广泛使用。本模块基于Image组件实现了简单的图片预览功能。 使用说明:双指捏合缩放图片大小 双击图片进行图片的大小切换 图片在放大模式下,滑动图片查看图片的对应位置效果图预览实现思路image组…

【python之DRF学习】三大方法之认证

title: 【python之DRF学习】三大方法之认证 date: 2024-04-17 21:00:56 星期三 updated: 2024-04-17 21:01:00 星期三 description: cover: 内置三大方法: drf之APIView内部的必须会经过的三大认证/方法: 认证、权限、频率一、认证组件 1、简介 登录认证的限制​ 认证组件…

软考——程序设计语言

1.低级语言和高级语言 计算机硬件只能识别由0、1组成的机器指令序列&#xff0c;即机器指令程序&#xff0c;因此机器指令是最基本的计算机语言。由于机器指令是特定的计算机系统所固有的、面向机器的语言&#xff0c;所以用机器语言进行程序设计时效率很低&#xff0c;程序的…

死锁

多个线程各自占有一些共享资源,并且互相等待其他线程占有的资源才能运行,而导致俩个或者多个线程都在等待对方释放资源。 package syn;public class DeadLock {public static void main(String[] args) {Makeup s1 = new Makeup(0,"小明");Makeup s2 = new Makeup(…

腾讯音乐:说说Redis脑裂问题?

Redis 脑裂问题是指,在 Redis 哨兵模式或集群模式中,由于网络原因,导致主节点(Master)与哨兵(Sentinel)和从节点(Slave)的通讯中断,此时哨兵就会误以为主节点已宕机,就会在从节点中选举出一个新的主节点,此时 Redis 的集群中就出现了两个主节点的问题,就是 Redis …

服务器挖矿病毒解决ponscan,定时任务解决

服务器挖矿病毒解决ponscan&#xff0c;定时任务解决 挖矿病毒会隐藏chattr的操作权限&#xff0c;让我们无法删除病毒文件&#xff0c;杀掉病毒进程。所以要去下载chattr.c的文件&#xff0c;编译成a.out。然后再对原来的chattr文件的权限进行修改。然后覆盖掉它。 chattr.c …

新标准日本语 课后练习

自学错误可能较多&#xff0c;听力题不需要听力的就没听录音 第二十課 スミスさんはピアノを弾くことができます 練習&#xff11;&#xff0d;&#xff11; &#xff11;張さんは日本の歌を歌うことができます 张先生会唱日本歌 &#xff12;小野さんは自転車に乗ることがで…

centos7 安装 Mysql 5.7.28,详细完整教程

https://cloud.tencent.com/developer/article/18863391. 下载 MySQL yum包wget http://repo.mysql.com/mysql57-community-release-el7-10.noarch.rpm 复制2.安装MySQL源rpm -Uvh mysql57-community-release-el7-10.noarch.rpm 复制3.安装MySQL服务端,需要等待一些时间yum ins…

openGauss Prometheus-Exporter组件环境部署

环境部署用户可以从Prometheus的官网上下载Prometheus-server和node-exporter,然后根据官方文档中的说明启动它们;也可以通过DBMind提供的快捷部署工具进行部署;如果用户自行部署,则可以跳到 部署过程中为支持部署位置正确以及后续的运行和监测...。通过命令行进行Promethe…

STM32无刷电机全套开发资料(源码、原理图、PCB工程及说明文档)

目录 1、原理图、PCB、BOOM表 2、设计描述 2.1 前言 2.2 设计电路规范 3、代码 4、资料清单 资料下载地址&#xff1a;STM32无刷电机全套开发资料(源码、原理图、PCB工程及说明文档) 1、原理图、PCB、BOOM表 2、设计描述 2.1 前言 经过一个星期的画PCB&#xff0c;今…

第 6 章 URDF、Gazebo与Rviz综合应用(自学二刷笔记)

重要参考&#xff1a; 课程链接:https://www.bilibili.com/video/BV1Ci4y1L7ZZ 讲义链接:Introduction Autolabor-ROS机器人入门课程《ROS理论与实践》零基础教程 6.7 URDF、Gazebo与Rviz综合应用 关于URDF(Xacro)、Rviz 和 Gazebo 三者的关系&#xff0c;前面已有阐述&…