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

【C++笔记】list使用详解及模拟实现

前言

各位读者朋友们大家好!上期我们讲了vector的使用以及底层的模拟实现,这期我们来讲list。

目录

  • 前言
  • 一. list的介绍及使用
    • 1.1 list的介绍
    • 1.2 list的使用
      • 1.2.1 list的构造
      • 1.2.2 list iterator的使用
      • 1.2.3 list capacity
      • 1.2.4 list element access
      • 1.2.5 list modifiers
  • 二. list的模拟实现
    • 2.1 list的底层结构
    • 2.2 普通迭代器
    • 2.3 const迭代器
    • 2.4 insert
    • 2.5 erase
    • 2.6 迭代器失效
    • 2.7 list的析构函数
    • 2.9 list的构造函数
    • 2.8 operator=
  • 三. 按需实例化
  • 四. initializer_list
  • 五. list.h
  • 结语

一. list的介绍及使用

1.1 list的介绍

list的文档
在这里插入图片描述
这里的list就是双向带头循环链表

在这里插入图片描述

1.2 list的使用

list的接口较多,我们要先掌握如何正确的使用,然后再去深入研究底层的原理,以达到可扩展的能力。以下是list的一些常见的重要接口。

1.2.1 list的构造

构造函数(Constructor)接口说明
list (size_type n, const value_type& val = value_type())构造的list中包含n个值为val的元素
list()构造空的list
list(const list& x)拷贝构造
list(InputItetator first,InputIterator last)用一段迭代器区间构造list
  • list (size_type n, const value_type& val = value_type())
    在这里插入图片描述
  • list()
    在这里插入图片描述
  • list(const list& x)
    在这里插入图片描述
  • list(InputItetator first,InputIterator last)
    在这里插入图片描述

1.2.2 list iterator的使用

这里我们暂时将list的迭代器理解为指针,该指针指向list中的某一节点

函数声明接口说明
begin + end返回第一个元素的迭代器+返回最后一个元素下一个位置的迭代器
rbegin + rend返回第一个元素的reverse_iterator,即end位置的迭代器+返回begin位置前一个位置的迭代器

可以看到这里的list的迭代器是双向的迭代器
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
如果想在某个位置插入元素就不能对迭代器进行+运算了
这里我们在第三个位置之前插入1314,要对begin进行三次自加,而不能使用begin+3

list<int> l(5, 520);
int k = 3;
list<int>::iterator it = l.begin();
while (k--)
{++it;
}
l.insert(it, 1314);
for (auto a : l)
{cout << a << " ";
}
cout << endl;

在这里插入图片描述

1.2.3 list capacity

函数声明接口说明
empty检测list是否为空,是返回true,否则返回false
size返回list的有效节点个数
void test_list2()
{list<int> l1,l2;if (l1.empty()){cout << "true" << endl;cout << l1.size() << endl;}else{cout << "false" << endl;cout << l1.size() << endl;}l2.push_back(1314);cout << l2.size() << endl;
}

在这里插入图片描述

1.2.4 list element access

函数声明接口说明
front返回list的第一个节点中的值的引用
back返回list的最后一个节点中的值的引用
void test_list3()
{list<int> l;l.push_back(520);l.push_back(520);l.push_back(520);l.push_back(520);for (auto a : l){cout << a << " ";}cout << endl;l.front() = 1314;l.back() = 1314;for (auto a : l){cout << a << " ";}
}

在这里插入图片描述
将第一个和最后一个位置的值改为了1314

1.2.5 list modifiers

函数声明接口说明
push_front在list首元素之前插入值为val的元素
pop_front删除list的第一个元素
push_back尾插值为val的元素
emplace_back尾插一个元素
pop_back将list的最后一个元素删除
insert在pos位置插入值为val的元素
erase删除pos位置的元素
  • push_front
    在这里插入图片描述

  • pop_front
    在这里插入图片描述

  • push_back 和 pop_back
    在这里插入图片描述

  • emplace_back
    在这里插入图片描述
    emplace_back在功能上跟push_back类似。但是emplace_back支持直接构造,不用再拷贝构造了,在最后一种情况下emplace_back比push_back高效。

  • insert 和 erase
    在这里插入图片描述

  • splice
    在这里插入图片描述
    将一个链表插到另一个链表的指定位置

void test_list4()
{list<int> lt1,lt2;lt1.push_back(520);lt1.push_back(520);lt2.push_back(1314);lt2.push_back(1314);lt1.splice(lt1.begin(), lt2);for (auto a : lt1){cout << a << " ";}cout << endl;for (auto a : lt2){cout << a << " ";}
}

在这里插入图片描述
插入后lt2就被置空了。
这一接口也可以用来调整结点的顺序
在这里插入图片描述

  • merge
    在这里插入图片描述
    这一功能的实现的是有序链表的合并
    在这里插入图片描述
    将大的尾插到一个头节点后最后将头节点接到lt1上

上面就讲完了list常用接口的使用,下面我们开始模拟实现list

二. list的模拟实现

2.1 list的底层结构

template <class T>// 链表的节点
struct list_node
{T _data;list_node<T>* _next;list_node<T>* _prev;list_node(const T& x = T()):_data(x), _next(nullptr), _prev(nullptr){}
};template <class T>
class list
{typedef list_node<T> Node;
public:
list()
{_head = new Node;_head->_next = _head;_head->_prev = _head;_size = 0;
}
private:Node* _head;size_t _size;
};

2.2 普通迭代器

因为list的节点在内存中不是连续存储的,因此不能使用原生指针作为迭代器,我们可以封装一个类来作为迭代器,通过运算符重载来实现迭代器的功能。

template <class T>
struct list_iterator
{typedef list_node<T> Node;typedef list_iterator<T> Self;Node* _node;list_iterator(Node* node):_node(node){}T& operator*(){return _node->_data;}T* 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 *this;}bool operator==(const Self& s) const{return _node == s._node;}bool operator!=(const Self& s) const{return _node != s._node;}
};

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

2.3 const迭代器

在这里插入图片描述
但是这样要写成两个类,而且两个类的方法只有两个不同,很是冗余,有没有方法能实现成一个类呢?
我们看一下库里是如何实现的:
在这里插入图片描述

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){}Ptr operator -> (){return &_node->_data;}Ref 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 *this;}bool operator==(const Self& s) const{return _node == s._node;}bool operator!=(const Self& s) const{return _node != s._node;}
};

写一段程序来体现一下实例化的过程
在这里插入图片描述

2.4 insert

在这里插入图片描述

iterator insert(iterator pos, const T& x)
{Node* newnode = new Node(x);Node* cur = pos._node;Node* prev = cur->_prev;// prev newnode curnewnode->_prev = prev;newnode->_next = cur;cur->_prev = newnode;prev->_next = newnode;++_size;return newnode;
}

有了insert我们可以服复用hinsert来实现push_back和push_front

void push_back(const T& x)
{insert(end(), x);
}
void push_front(const T& x)
{insert(begin(), x);
}

2.5 erase

将pos节点的前节点和后节点相连然后将pos节点释放即可
在这里插入图片描述

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

有了erase就可以复用erase来实现pop_back和pop_front了

void pop_back()
{erase(--end());
}
void pop_front()
{erase(begin());
}

2.6 迭代器失效

在这里插入图片描述

2.7 list的析构函数

~list()
{clear();delete _head;_head = nullptr;
}
void clear()
{auto it = begin();while (it != end()){it = erase(it);}
}

将所有节点删除之后再将头结点释放

2.9 list的构造函数

void empty_init()
{_head = new Node;_head->_next = _head;_head->_prev = _head;_size = 0;
}
list()
{empty_init();
}
list(const list<T>& tmp)
{empty_init();for (auto& a : tmp){push_back(a);}
}

构造一个头节点,将tmp的节点尾插到头节点后

2.8 operator=

	list<T>& operator=(list<T> tmp){swap(tmp);return *this;}

依旧是现代写法
在这里插入图片描述

三. 按需实例化

编译器在对模板进行实例化的时候,使用哪些成员函数就实例化哪些成员函数,不会全部实例化。
在这里插入图片描述

四. initializer_list

C++11中支持下面的写法:
在这里插入图片描述
不需要一直push_back数据,这里是因为支持了initializer_list
在这里插入图片描述
initializer_list底层是两个指针,第一个指针指向第一个数据,第二个指针指向最后一个数据的下一位置
在这里插入图片描述
我们写的list如果要支持这种写法需要写一个新的构造函数
在这里插入图片描述

list(initializer_list<T> il)
{empty_init();for (auto& a : il){push_back(a);}
}

跟普通的构造函数一样,只是参数变了而已,最正确的写法应该如下,因为我们是构造函数
在这里插入图片描述
在这里插入图片描述
这样就是隐式类型转换了
在这里插入图片描述
所以就有了下面的玩法:
在这里插入图片描述

五. list.h

namespace Yuey
{template <class T>// 链表的节点struct list_node{T _data;list_node<T>* _next;list_node<T>* _prev;list_node(const T& x = T()):_data(x), _next(nullptr), _prev(nullptr){}};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){}Ptr operator -> (){return &_node->_data;}Ref 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 *this;}bool operator==(const Self& s) const{return _node == s._node;}bool operator!=(const Self& s) const{return _node != s._node;}};struct AA{int _a1 = 520;int _a2 = 1314;};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;void empty_init(){_head = new Node;_head->_next = _head;_head->_prev = _head;_size = 0;}list(){empty_init();}list(initializer_list<T> il){empty_init();for (auto& a : il){push_back(a);}}list(const list<T>& tmp){empty_init();for (auto& a : tmp){push_back(a);}}~list(){clear();delete _head;_head = nullptr;}void clear(){auto it = begin();while (it != end()){it = erase(it);}}void swap(list<T>& tmp){std::swap(_head, tmp._head);std::swap(_size, tmp._size);}list<T>& operator=(list<T> tmp){swap(tmp);return *this;}iterator begin(){return iterator(_head->_next);}iterator end(){return _head;}const_iterator begin() const{return const_iterator(_head->_next);}const_iterator end() const{return _head;}iterator insert(iterator pos, const T& x){Node* newnode = new Node(x);Node* cur = pos._node;Node* prev = cur->_prev;// prev newnode curnewnode->_prev = prev;newnode->_next = cur;cur->_prev = newnode;prev->_next = newnode;++_size;return newnode;}void push_back(const T& x){insert(end(), x);}void push_front(const T& x){insert(begin(), x);}iterator erase(iterator pos){assert(pos != end());Node* next = pos._node->_next;Node* prev = pos._node->_prev;next->_prev = prev;prev->_next = next;delete pos._node;--_size;return next;}void pop_back(){erase(--end());}void pop_front(){erase(begin());}private:Node* _head;size_t _size;};
}

结语

以上我们就讲完了list的用法以及模拟实现,希望对大家有所帮助,感谢大家的阅读,欢迎大家批评指正!

相关文章:

【C++笔记】list使用详解及模拟实现

前言 各位读者朋友们大家好&#xff01;上期我们讲了vector的使用以及底层的模拟实现&#xff0c;这期我们来讲list。 目录 前言一. list的介绍及使用1.1 list的介绍1.2 list的使用1.2.1 list的构造1.2.2 list iterator的使用1.2.3 list capacity1.2.4 list element access1.…...

【机器学习】机器学习中用到的高等数学知识-7.信息论 (Information Theory)

熵 (Entropy)&#xff1a;用于评估信息的随机性&#xff0c;常用于决策树和聚类算法。交叉熵 (Cross-Entropy)&#xff1a;用于衡量两个概率分布之间的差异&#xff0c;在分类问题中常用。 信息论作为处理信息量和信息传输的数学理论&#xff0c;在机器学习中具有广泛的应用。…...

《现代制造技术与装备》是什么级别的期刊?是正规期刊吗?能评职称吗?

​问题解答 问&#xff1a;《现代制造技术与装备》是不是核心期刊&#xff1f; 答&#xff1a;不是&#xff0c;是知网收录的第二批认定学术期刊。 问&#xff1a;《现代制造技术与装备》级别&#xff1f; 答&#xff1a;省级。主管单位&#xff1a;齐鲁工业大学&#xff0…...

09 - Clickhouse的SQL操作

目录 1、Insert 1.1、标准 1.2、从表到表的插入 2、Update和Delete 2.1、删除操作 2.2、修改操作 3、查询操作 3.1、with rollup&#xff1a;从右至左去掉维度进行小计 3.2、with cube : 从右至左去掉维度进行小计&#xff0c;再从左至右去掉维度进行小计 3.3、with …...

如何解决pdf.js跨域从url动态加载pdf文档

摘要 当我们想用PDF.js从URL加载文档时&#xff0c;将会因遇到跨域问题而中断&#xff0c;且是因为会触发了PDF.js和浏览器的双重CORS block&#xff0c;这篇文章将会介绍&#xff1a;①如何禁用pdf.js的跨域&#xff1f;②如何绕过浏览器的CORS加载URL文件&#xff1f;②如何使…...

深入理解TTY体系:设备节点与驱动程序框架详解

往期内容 本专栏往期内容&#xff1a;Uart子系统 UART串口硬件介绍 interrupt子系统专栏&#xff1a; 专栏地址&#xff1a;interrupt子系统Linux 链式与层级中断控制器讲解&#xff1a;原理与驱动开发 – 末片&#xff0c;有专栏内容观看顺序 pinctrl和gpio子系统专栏&#xf…...

库的操作(MySQL)

1.创建数据库 语法&#xff1a; CREATE DATABASE [IF NOT EXISTS] db_name [create_specification [, create_specification] ...] create_specification:[DEFAULT] CHARACTER SET charset_name[DEFAULT] COLLATE collation_name说明&#xff1a; 大写的表示关键字 [ ] 是可…...

在 for 循环中,JVM可能会将 arr.length 提升到循环外部,仅计算一次。可能会将如何解释 详解

在 Java 的 for 循环中&#xff0c;JVM 有能力进行优化&#xff0c;将 arr.length 的访问提升到循环外部&#xff0c;避免每次迭代都重新计算 arr.length。这种优化主要是由于 JVM 的 即时编译器&#xff08;JIT&#xff09; 和 逃逸分析&#xff08;Escape Analysis&#xff0…...

回溯--数据在内存中的存储:整数、大小端和浮点数的深度解析

目录 引言 1. 整数在内存中的存储 1.1 原码、反码和补码 1.2 为什么使用补码&#xff1f; 1.3 示例代码&#xff1a;整数的存储 2. 大小端字节序和字节序判断 2.1 什么是大端和小端&#xff1f; 2.2 为什么会有大端和小端之分&#xff1f; 2.3 字节序的判断小程序 2.…...

第二十二章 Spring之假如让你来写AOP——Target Object(目标对象)篇

Spring源码阅读目录 第一部分——IOC篇 第一章 Spring之最熟悉的陌生人——IOC 第二章 Spring之假如让你来写IOC容器——加载资源篇 第三章 Spring之假如让你来写IOC容器——解析配置文件篇 第四章 Spring之假如让你来写IOC容器——XML配置文件篇 第五章 Spring之假如让你来写…...

探索设计模式:原型模式

设计模式之原型模式 &#x1f9d0;1. 概念&#x1f3af;2. 原型模式的作用&#x1f4e6;3. 实现1. 定义原型接口2. 定义具体的原型类3. 定义客户端4. 结果 &#x1f4f0; 4. 应用场景&#x1f50d;5. 深拷贝和浅拷贝 在面向对象编程中&#xff0c;设计模式是一种通用的解决方案…...

NLP论文速读(EMNLP 2023)|工具增强的思维链推理

论文速读|ChatCoT: Tool-Augmented Chain-of-Thought Reasoning on Chat-based Large Language Models 论文信息&#xff1a; 简介&#xff1a; 本文背景是关于大型语言模型&#xff08;LLMs&#xff09;在复杂推理任务中的表现。尽管LLMs在多种评估基准测试中取得了优异的成绩…...

JVM垃圾回收详解.②

空间分配担保 空间分配担保是为了确保在 Minor GC 之前老年代本身还有容纳新生代所有对象的剩余空间。 《深入理解 Java 虚拟机》第三章对于空间分配担保的描述如下&#xff1a; JDK 6 Update 24 之前&#xff0c;在发生 Minor GC 之前&#xff0c;虚拟机必须先检查老年代最大…...

什么是事务,事务有什么特性?

事务的四大特性&#xff08;ACID&#xff09; 原子性&#xff08;Atomicity&#xff09; 解释&#xff1a;原子性确保事务中的所有操作要么全部完成&#xff0c;要么全部不做。这意味着事务是一个不可分割的工作单元。在数据库中&#xff0c;这通常通过将事务的操作序列作为一个…...

深入解析:如何使用 PyTorch 的 SummaryWriter 进行深度学习训练数据的详细记录与可视化

深入解析&#xff1a;如何使用 PyTorch 的 SummaryWriter 进行深度学习训练数据的详细记录与可视化 为了更全面和详细地解释如何使用 PyTorch 的 SummaryWriter 进行模型训练数据的记录和可视化&#xff0c;我们可以从以下几个方面深入探讨&#xff1a; 初始化 SummaryWriter…...

企业微信中设置回调接口url以及验证 spring boot项目实现

官方文档&#xff1a; 接收消息与事件&#xff1a; 加密解密文档&#xff1a;加解密库下载与返回码 - 文档 - 企业微信开发者中心 下载java样例 加解密库下载与返回码 - 文档 - 企业微信开发者中心 将解压开的代码 ‘将文件夹&#xff1a;qq\weixin\mp\aes的代码作为工具拷…...

电脑超频是什么意思?超频的好处和坏处

嗨&#xff0c;亲爱的小伙伴&#xff01;你是否曾经听说过电脑超频&#xff1f;在电脑爱好者的圈子里&#xff0c;这个词似乎非常熟悉&#xff0c;但对很多普通用户来说&#xff0c;它可能还是一个神秘而陌生的存在。 今天&#xff0c;我将带你揭开超频的神秘面纱&#xff0c;…...

在 AMD GPU 上构建深度学习推荐模型

Deep Learning Recommendation Models on AMD GPUs — ROCm Blogs 2024 年 6 月 28 日 发布者 Phillip Dang 在这篇博客中&#xff0c;我们将演示如何在支持 ROCm 的 AMD GPU 上使用 PyTorch 构建一个简单的深度学习推荐模型 (DLRM)。 简介 DLRM 位于推荐系统和深度学习的交汇…...

阿里云IIS虚拟主机部署ssl证书

宝塔配置SSL证书用起来是很方便的&#xff0c;只需要在站点里就可以配置好&#xff0c;但是云虚拟主机在管理的时候是没有这个权限的&#xff0c;只提供了简单的域名管理等信息。 此处记录下阿里云&#xff08;原万网&#xff09;的IIS虚拟主机如何配置部署SSL证书。 进入虚拟…...

Python运算符列表

运算符 描述 xy&#xff0c;x—y 加、减,“"号可重载为连接符 x*y,x*&#xff0a;y&#xff0c;x/y,x&#xff05;y 相乘、求平方、相除、求余&#xff0c;“*”号可重载为重复&#xff0c;“&#xff05;"号可重载为格式化 <&#xff0c;<&#xff0c;&…...

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

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

【Python】 -- 趣味代码 - 小恐龙游戏

文章目录 文章目录 00 小恐龙游戏程序设计框架代码结构和功能游戏流程总结01 小恐龙游戏程序设计02 百度网盘地址00 小恐龙游戏程序设计框架 这段代码是一个基于 Pygame 的简易跑酷游戏的完整实现,玩家控制一个角色(龙)躲避障碍物(仙人掌和乌鸦)。以下是代码的详细介绍:…...

使用分级同态加密防御梯度泄漏

抽象 联邦学习 &#xff08;FL&#xff09; 支持跨分布式客户端进行协作模型训练&#xff0c;而无需共享原始数据&#xff0c;这使其成为在互联和自动驾驶汽车 &#xff08;CAV&#xff09; 等领域保护隐私的机器学习的一种很有前途的方法。然而&#xff0c;最近的研究表明&…...

【android bluetooth 框架分析 04】【bt-framework 层详解 1】【BluetoothProperties介绍】

1. BluetoothProperties介绍 libsysprop/srcs/android/sysprop/BluetoothProperties.sysprop BluetoothProperties.sysprop 是 Android AOSP 中的一种 系统属性定义文件&#xff08;System Property Definition File&#xff09;&#xff0c;用于声明和管理 Bluetooth 模块相…...

爬虫基础学习day2

# 爬虫设计领域 工商&#xff1a;企查查、天眼查短视频&#xff1a;抖音、快手、西瓜 ---> 飞瓜电商&#xff1a;京东、淘宝、聚美优品、亚马逊 ---> 分析店铺经营决策标题、排名航空&#xff1a;抓取所有航空公司价格 ---> 去哪儿自媒体&#xff1a;采集自媒体数据进…...

C#中的CLR属性、依赖属性与附加属性

CLR属性的主要特征 封装性&#xff1a; 隐藏字段的实现细节 提供对字段的受控访问 访问控制&#xff1a; 可单独设置get/set访问器的可见性 可创建只读或只写属性 计算属性&#xff1a; 可以在getter中执行计算逻辑 不需要直接对应一个字段 验证逻辑&#xff1a; 可以…...

解决:Android studio 编译后报错\app\src\main\cpp\CMakeLists.txt‘ to exist

现象&#xff1a; android studio报错&#xff1a; [CXX1409] D:\GitLab\xxxxx\app.cxx\Debug\3f3w4y1i\arm64-v8a\android_gradle_build.json : expected buildFiles file ‘D:\GitLab\xxxxx\app\src\main\cpp\CMakeLists.txt’ to exist 解决&#xff1a; 不要动CMakeLists.…...

tomcat入门

1 tomcat 是什么 apache开发的web服务器可以为java web程序提供运行环境tomcat是一款高效&#xff0c;稳定&#xff0c;易于使用的web服务器tomcathttp服务器Servlet服务器 2 tomcat 目录介绍 -bin #存放tomcat的脚本 -conf #存放tomcat的配置文件 ---catalina.policy #to…...

「全栈技术解析」推客小程序系统开发:从架构设计到裂变增长的完整解决方案

在移动互联网营销竞争白热化的当下&#xff0c;推客小程序系统凭借其裂变传播、精准营销等特性&#xff0c;成为企业抢占市场的利器。本文将深度解析推客小程序系统开发的核心技术与实现路径&#xff0c;助力开发者打造具有市场竞争力的营销工具。​ 一、系统核心功能架构&…...

通过 Ansible 在 Windows 2022 上安装 IIS Web 服务器

拓扑结构 这是一个用于通过 Ansible 部署 IIS Web 服务器的实验室拓扑。 前提条件&#xff1a; 在被管理的节点上安装WinRm 准备一张自签名的证书 开放防火墙入站tcp 5985 5986端口 准备自签名证书 PS C:\Users\azureuser> $cert New-SelfSignedCertificate -DnsName &…...