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

单链表的多语言表达:C++、Java、Python、Go、Rust

单链表

是一种链式数据结构,由一个头节点和一些指向下一个节点的指针组成。每个节点包含一个数据元素和指向下一个节点的指针。头节点没有数据,只用于表示链表的开始位置。

单链表的主要操作包括:

  1. 添加元素:在链表的头部添加新元素,需要修改头节点的指针。
  2. 删除元素:删除链表中的元素,需要修改头节点和其他节点的指针。
  3. 查找元素:在链表中查找某个元素,需要遍历整个链表。
  4. 遍历链表:按照链表的顺序依次访问每个元素,需要遍历整个链表。

单链表相对于数组的优点是插入和删除元素时不需要移动其他元素,时间复杂度为O(1)。但是,在查找元素时,单链表比数组要慢,时间复杂度为O(n)。

20210817204340750.png

本文总结了 C++、Java、Python、Go、Rust 五种语言的单链表的表达:

C++

c++语言既可以用struct也能用class来表示链表节点,类可以定义方法调用相对方便。另外C++类需要自定义析构函数用以退出时释放节点所占空间,其它语言有自动的垃圾回收机制。

struct 

// 定义结构体 Node,表示链表中的节点
struct Node {
    int data;  // 节点的数据
    Node* next;  // 指向下一个节点的指针
};

// 定义类 LinkedList,表示链表
class LinkedList {
private:
    Node* head;  // 指向链表头节点的指针
}

代码:

#include <iostream>using namespace std;// 定义结构体 Node,表示链表中的节点
struct Node {int data;  // 节点的数据Node* next;  // 指向下一个节点的指针
};// 定义类 LinkedList,表示链表
class LinkedList {
private:Node* head;  // 指向链表头节点的指针public:// 构造函数,初始化链表为空链表LinkedList() {head = NULL;}// 析构函数,释放链表中的所有节点~LinkedList() {Node* curr = head;while (curr != NULL) {Node* next = curr->next;delete curr;curr = next;}}// 在链表头部添加一个新节点void add(int value) {Node* newNode = new Node;newNode->data = value;newNode->next = head;head = newNode;}// 在链表尾部添加一个新节点void push(int value) {Node* newNode = new Node;newNode->data = value;newNode->next = NULL;if (head == NULL) {head = newNode;} else {Node* curr = head;while (curr->next != NULL) {curr = curr->next;}curr->next = newNode;}}// 删除最后一个节点,并返回该节点的数据 int pop() {if (head == NULL) {return -1;} else if (head->next == NULL) {int data = head->data;delete head;head = NULL;return data;} else {Node* curr = head;while (curr->next->next != NULL) {curr = curr->next;}int data = curr->next->data;delete curr->next;curr->next = NULL;return data;}}// 遍历链表,打印每个节点的数据void traverse() {Node* curr = head;while (curr != NULL) {cout << curr->data << "->";curr = curr->next;}cout << "nil" << endl;}
};int main() {LinkedList list;list.traverse();  // 打印空链表 nillist.add(1);  // 在链表头部添加节点 1list.traverse();  // 打印链表 1->nillist.add(2);  // 在链表头部添加节点 2list.traverse();  // 打印链表 2->1->nillist.add(3);  // 在链表头部添加节点 3list.traverse();  // 打印链表 3->2->1->nillist.push(4);  // 在链表尾部添加节点 4list.traverse();  // 打印链表 3->2->1->4->nillist.push(5);  // 在链表尾部添加节点 5list.traverse();  // 打印链表 3->2->1->4->5->nilcout << list.pop() << endl;  // 删除尾节点,并输出节点数据list.traverse();  // 打印链表 3->2->1->4->nilcout << list.pop() << endl;  // 删除尾节点,并输出节点数据list.traverse();  // 打印链表 3->2->1->nilreturn 0;
}

class

// 定义类 Node,表示链表中的节点
class Node {
public:
    int data;
    Node* next;
    Node(int value) {
        data = value;
        next = NULL;
    }
};

// 定义类 LinkedList,表示链表
class LinkedList {
private:
    Node* head;  // 指向链表头节点的指针
};

代码:

#include <iostream>using namespace std;// 定义类 Node,表示链表中的节点
class Node {
public:int data;Node* next;Node(int value) {data = value;next = NULL;}
};// 定义类 LinkedList,表示链表
class LinkedList {
private:Node* head;  // 指向链表头节点的指针public:// 构造函数,初始化链表为空链表LinkedList() {head = NULL;}// 析构函数,释放链表中的所有节点~LinkedList() {Node* curr = head;while (curr != NULL) {Node* next = curr->next;delete curr;curr = next;}}// 在链表头部添加一个新节点void add(int value) {Node* newNode = new Node(value);newNode->next = head;head = newNode;}// 在链表尾部添加一个新节点void push(int value) {Node* newNode = new Node(value);newNode->next = NULL;if (head == NULL) {head = newNode;} else {Node* curr = head;while (curr->next != NULL) {curr = curr->next;}curr->next = newNode;}}// 删除最后一个节点,并返回该节点的数据 int pop() {if (head == NULL) {return -1;} else if (head->next == NULL) {int data = head->data;delete head;head = NULL;return data;} else {Node* curr = head;while (curr->next->next != NULL) {curr = curr->next;}int data = curr->next->data;delete curr->next;curr->next = NULL;return data;}}// 遍历链表,打印每个节点的数据void traverse() {Node* curr = head;while (curr != NULL) {cout << curr->data << "->";curr = curr->next;}cout << "nil" << endl;}
};int main() {LinkedList list;list.traverse();  // 打印空链表 nillist.add(1);  // 在链表头部添加节点 1list.traverse();  // 打印链表 1->nillist.add(2);  // 在链表头部添加节点 2list.traverse();  // 打印链表 2->1->nillist.add(3);  // 在链表头部添加节点 3list.traverse();  // 打印链表 3->2->1->nillist.push(4);  // 在链表尾部添加节点 4list.traverse();  // 打印链表 3->2->1->4->nillist.push(5);  // 在链表尾部添加节点 5list.traverse();  // 打印链表 3->2->1->4->5->nilcout << list.pop() << endl;  // 删除尾节点,并输出节点数据list.traverse();  // 打印链表 3->2->1->4->nilcout << list.pop() << endl;  // 删除尾节点,并输出节点数据list.traverse();  // 打印链表 3->2->1->nilreturn 0;
}

Java

Java没有跟C或Go类似的struct结构体,只有用类class来表达。

class 

public class LinkedList {
    public class Node {
        public int data;
        public Node next;

        public Node(int value) {
            data = value;
            next = null;
        }
    }

    public LinkedList() {
        head = null;
    }
}

代码:

public class LinkedList {public class Node {public int data;public Node next;public Node(int value) {data = value;next = null;}}public LinkedList() {head = null;}private Node head;// 在链表头部添加一个新的节点public void add(int value) {Node newNode = new Node(value);newNode.next = head;head = newNode;}// 在链表尾部添加一个新的节点public void push(int value) {Node newNode = new Node(value);if (head == null) {head = newNode;} else {Node curr = head;while (curr.next != null) {curr = curr.next;}curr.next = newNode;}}// 删除尾节点,并返回该节点的数据public int pop() {if (head == null) {return -1;} else if (head.next == null) {int data = head.data;head = null;return data;} else {Node curr = head;while (curr.next.next != null) {curr = curr.next;}Node tail = curr.next;curr.next = null;return tail.data;}}// 遍历链表,打印每个节点的数据public void traverse() {Node curr = head;while (curr != null) {System.out.print(curr.data + "->");curr = curr.next;}System.out.println("nil");}public static void main(String[] args) {LinkedList list = new LinkedList();list.traverse();  // 打印空链表 nillist.add(1);  // 在链表头部添加节点 1list.traverse();  // 打印链表 1->nillist.add(2);  // 在链表头部添加节点 2list.traverse();  // 打印链表 2->1->nillist.add(3);  // 在链表头部添加节点 3list.traverse();  // 打印链表 3->2->1->nillist.push(4);  // 在链表尾部添加节点 4list.traverse();  // 打印链表 3->2->1->4->nillist.push(5);  // 在链表尾部添加节点 5list.traverse();  // 打印链表 3->2->1->4->5->nilSystem.out.println(list.pop());  // 删除尾节点,并输出节点数据list.traverse();  // 打印链表 3->2->1->4->nilSystem.out.println(list.pop());  // 删除尾节点,并输出节点数据list.traverse();  // 打印链表 3->2->1->nil}
}

Python

Python也没有struct结构体,只能用类class来表达。而且python是动态类型语言,变量在创建时无需显式指定类型,也没有指针概念。

class 

class Node:
    def __init__(self, data):
        self.data = data  # 节点的数据
        self.next = None  # 节点的下一个指针,初始为空

class LinkedList:
    def __init__(self):
        self.head = None  # 链表的头指针,初始为空

代码:

class Node:def __init__(self, data):self.data = data  # 节点的数据self.next = None  # 节点的下一个指针,初始为空class LinkedList:def __init__(self):self.head = None  # 链表的头指针,初始为空def add(self, data):# 在链表头部插入一个新节点newNode = Node(data)newNode.next = self.headself.head = newNodedef push(self, data):# 在链表尾部添加一个新节点newNode = Node(data)if self.head is None:self.head = newNodeelse:curr = self.headwhile curr.next is not None:curr = curr.nextcurr.next = newNodedef pop(self):# 删除尾节点,并返回该节点的值if self.head is None:return Noneif self.head.next is None:data = self.head.dataself.head = Nonereturn datacurr = self.headwhile curr.next.next is not None:curr = curr.nexttail = curr.nextcurr.next = Nonereturn tail.datadef traverse(self):# 遍历链表,打印每个节点的数据curr = self.headwhile curr is not None:print(curr.data, end='->')curr = curr.nextprint('nil')if __name__ == '__main__':head = LinkedList() # 创建链表head.traverse()     # 遍历空链表head.add(1)         # 在链表头部添加节点 1head.traverse()     # 遍历链表 1->nilhead.add(2)         # 在链表头部添加节点 2head.traverse()     # 遍历链表 2->1->nilhead.add(3)         # 在链表头部添加节点 3head.traverse()     # 遍历链表 3->2->1->nilhead.push(4)        # 在链表尾部添加节点 4head.traverse()     # 遍历链表 3->2->1->4->nilhead.push(5)        # 在链表尾部添加节点 5head.traverse()     # 遍历链表 3->2->1->4->5->nilprint(head.pop())   # 删除尾节点,并输出节点数据head.traverse()     # 打印链表 3->2->1->4->nilprint(head.pop())   # 删除尾节点,并输出节点数据head.traverse()     # 打印链表 3->2->1->nil

Golang

Go没有class类,使用结构体 struct 来代替类。结构体可以包含字段(成员变量),并且可以定义方法(成员函数)来操作结构体的数据。

struct

type Node struct {
    data int
    next *Node
}

type LinkedList struct {
    head *Node
}

// 创建一个新的节点
func new(value int) *Node {
    return &Node{
        data: value,
        next: nil,
    }
}

代码:

package mainimport "fmt"type Node struct {data intnext *Node
}type LinkedList struct {head *Node
}// 创建一个新的节点
func new(value int) *Node {return &Node{data: value,next: nil,}
}// 在链表头部添加一个新节点
func (list *LinkedList) add(value int) {newNode := new(value)newNode.next = list.headlist.head = newNode
}// 在链表尾部添加一个新节点
func (list *LinkedList) push(value int) {newNode := new(value)if list.head == nil {list.head = newNode} else {curr := list.headfor curr.next != nil {curr = curr.next}curr.next = newNode}
}// 删除尾节点,并返回该节点的值
func (list *LinkedList) pop() int {if list.head == nil {return -1} else if list.head.next == nil {data := list.head.datalist.head = nilreturn data} else {curr := list.headfor curr.next.next != nil {curr = curr.next}tail := curr.nextcurr.next = nilreturn tail.data}
}// 遍历链表,打印每个节点的数据
func (list *LinkedList) traverse() {curr := list.headfor curr != nil {fmt.Printf("%d->", curr.data)curr = curr.next}fmt.Println("nil")
}func main() {list := LinkedList{}list.traverse()         // 打印空链表 nillist.add(1)             // 在链表头部添加节点 1list.traverse()         // 打印链表 1->nillist.add(2)             // 在链表头部添加节点 2list.traverse()         // 打印链表 2->1->nillist.add(3)             // 在链表头部添加节点 3list.traverse()         // 打印链表 3->2->1->nillist.push(4)            // 在链表尾部添加节点 4list.traverse()         // 打印链表 3->2->1->4->nillist.push(5)            // 在链表尾部添加节点 5list.traverse()         // 打印链表 3->2->1->4->5->nilfmt.Println(list.pop()) // 删除尾节点,并打印数据list.traverse()         // 打印链表 3->2->1->4->nilfmt.Println(list.pop()) // 删除尾节点,并打印数据list.traverse()         // 打印链表 3->2->1->nil
}

Rust

Rust中也没有类的概念,但它提供了结构体 struct 和 trait 两种重要的机制来实现面向对象的编程风格。结构体用于定义数据结构,而 trait 则用于定义方法集合。

另外在Rust中,一般不使用unsafe指针std::ptr来操作链表,而是 Option 类型来表示链表指针,它代表的值可以存在(Some)也可以不存在(None)。Option 类型被广泛用于处理可能为空的值,以避免出现空指针异常。

struct

struct Node {
    data: i32,
    next: Option<Box<Node>>,
}

impl Node {
    fn new(value: i32) -> Node {
        Node { data: value, next: None }
    }
}

struct LinkedList {
    head: Option<Box<Node>>,
}

impl LinkedList {
    fn new() -> LinkedList {
        LinkedList { head: None }
    }
}

代码:

struct Node {data: i32,next: Option<Box<Node>>,
}impl Node {fn new(value: i32) -> Node {Node { data: value, next: None }}
}struct LinkedList {head: Option<Box<Node>>,
}impl LinkedList {fn new() -> LinkedList {LinkedList { head: None }}// 在链表头部添加一个新节点fn add(&mut self, value: i32) {let mut new_node = Box::new(Node::new(value));new_node.next = self.head.take();self.head = Some(new_node);}// 在链表尾部添加一个新节点fn push(&mut self, value: i32) {let new_node = Box::new(Node::new(value));let mut curr = &mut self.head;while let Some(node) = curr {curr = &mut node.next;}*curr = Some(new_node);}// 删除尾节点,并返回该节点的数据fn pop(&mut self) -> Option<i32> {if self.head.is_none() {return None;}if self.head.as_ref().unwrap().next.is_none() {let data = self.head.take().unwrap().data;return Some(data);}let mut curr = self.head.as_mut().unwrap();while curr.next.as_ref().unwrap().next.is_some() {curr = curr.next.as_mut().unwrap();}let data = curr.next.take().unwrap().data;Some(data)}// 遍历链表,打印每个节点的数据fn traverse(&self) {let mut curr = &self.head;while let Some(node) = curr {print!("{}->", node.data);curr = &node.next;}println!("nil");}
}fn main() {let mut list = LinkedList::new();list.traverse();  // 打印空链表 nillist.add(1);  // 在链表头部添加节点 1list.traverse();  // 打印链表 1->nillist.add(2);  // 在链表头部添加节点 2list.traverse();  // 打印链表 2->1->nillist.add(3);  // 在链表头部添加节点 3list.traverse();  // 打印链表 3->2->1->nillist.push(4);  // 在链表尾部添加节点 4list.traverse();  // 打印链表 3->2->1->4->nillist.push(5);  // 在链表尾部添加节点 5list.traverse();  // 打印链表 3->2->1->4->5->nilprintln!("{}", list.pop().unwrap());  // 删除尾节点,并输出节点数据list.traverse();  // 打印链表 3->2->1->4->nilprintln!("{}", list.pop().unwrap());  // 删除尾节点,并输出节点数据list.traverse();  // 打印链表 3->2->1->nil
}

struct unsafe

struct Node {
    data: i32,
    next: *mut Node,
}

impl Node {
    fn new(value: i32) -> Node {
        Node { data: value, next: std::ptr::null_mut() }
    }
}

struct LinkedList {
    head: *mut Node,
}

impl LinkedList {
    fn new() -> LinkedList {
        LinkedList { head: std::ptr::null_mut() }
    }
}

代码:

struct Node {data: i32,next: *mut Node,
}impl Node {fn new(value: i32) -> Node {Node { data: value, next: std::ptr::null_mut() }}
}struct LinkedList {head: *mut Node,
}impl LinkedList {fn new() -> LinkedList {LinkedList { head: std::ptr::null_mut() }}fn add(&mut self, value: i32) {let mut new_node = Box::new(Node::new(value));new_node.next = self.head;self.head = Box::into_raw(new_node);}fn push(&mut self, value: i32) {let new_node = Box::new(Node::new(value));let mut curr = &mut self.head;while !(*curr).is_null() {curr = unsafe { &mut (**curr).next };}*curr = Box::into_raw(new_node);}fn pop(&mut self) -> Option<i32> {if self.head.is_null() {return None;}let mut curr = self.head;let mut prev = std::ptr::null_mut();while unsafe { !(*curr).next.is_null() } {prev = curr;curr = unsafe { (*curr).next };}let data = unsafe { Box::from_raw(curr) }.data;if prev.is_null() {self.head = std::ptr::null_mut();} else {unsafe { (*prev).next = std::ptr::null_mut(); }}Some(data)}fn traverse(&self) {let mut curr = self.head;while !curr.is_null() {unsafe {print!("{}->", (*curr).data);curr = (*curr).next;}}println!("nil");}fn cleanup(&mut self) {let mut curr = self.head;while !curr.is_null() {let next = unsafe { (*curr).next };unsafe { Box::from_raw(curr) };curr = next;}}
}fn main() {let mut list = LinkedList::new();list.traverse();  // 打印空链表 nillist.add(1);list.traverse();list.add(2);list.traverse();list.add(3);list.traverse();list.push(4);list.traverse();list.push(5);list.traverse();println!("{}", list.pop().unwrap());list.traverse();println!("{}", list.pop().unwrap());list.traverse();list.cleanup();
}

cleanup()相当于析构函数,用于释放链表所占空间。


以上所有示例代码的输出都相同:

nil
1->nil
2->1->nil
3->2->1->nil
3->2->1->4->nil
3->2->1->4->5->nil
5
3->2->1->4->nil
4
3->2->1->nil

其中,Rust的节点值有点特殊,使用了Some类型。比如:

使用println!("{:?}", list.pop());  不需要pop()后面的.unwrap(),返回Some(n);当链表为空时,直接返回None。


相关文章:

单链表的多语言表达:C++、Java、Python、Go、Rust

单链表 是一种链式数据结构&#xff0c;由一个头节点和一些指向下一个节点的指针组成。每个节点包含一个数据元素和指向下一个节点的指针。头节点没有数据&#xff0c;只用于表示链表的开始位置。 单链表的主要操作包括&#xff1a; 添加元素&#xff1a;在链表的头部添加新…...

微信小程序 background-image直接设置本地图片路径,编辑器正常显示,真机运行不显示解决方法

项目场景 微信小程序&#xff0c;设置background-image直接设置本地图片路径。 问题描述 编辑器正常显示&#xff0c;真机运行不显示 原因分析 background-image只能用网络url或者base64图片编码。 解决方案 1、将本地图片转为网络url后设置到background-image上 例如&…...

SQLite Studio 连接 SQLite数据库

1、在SQLite中创建数据库和表 1.1、按WINR&#xff0c;打开控制台&#xff0c;然后把指引到我们的SQLite的安装路径&#xff0c;输入D:&#xff0c;切换到D盘&#xff0c;cd 地址&#xff0c;切换到具体文件夹&#xff0c;输入“sqlite3”&#xff0c;启动服务 1.2、创建数据库…...

【业务功能篇58】Springboot + Spring Security 权限管理 【中篇】

4.2.3 认证 4.2.3.1 什么是认证&#xff08;Authentication&#xff09; 通俗地讲就是验证当前用户的身份&#xff0c;证明“你是你自己”&#xff08;比如&#xff1a;你每天上下班打卡&#xff0c;都需要通过指纹打卡&#xff0c;当你的指纹和系统里录入的指纹相匹配时&…...

Docker挂载目录失败问题解决

天行健&#xff0c;君子以自强不息&#xff1b;地势坤&#xff0c;君子以厚德载物。 每个人都有惰性&#xff0c;但不断学习是好好生活的根本&#xff0c;共勉&#xff01; 文章均为学习整理笔记&#xff0c;分享记录为主&#xff0c;如有错误请指正&#xff0c;共同学习进步。…...

css中隐藏页面中某一个元素有什么方法?

我们可以使用css的z-index属性&#xff0c;将元素的-index去给它设置一个负值&#xff0c;使它隐藏在其他元素的后面。使用css样式进行隐藏我们可以使用display这个属性。&#xff08;1&#xff09;使用display:none完全进行隐藏元素&#xff0c;并且不占据空间也不会影响页面布…...

Unity 多语言问题C#篇

DateTime.ToString()不同语言环境问题 问题描述&#xff1a;PlayerPrefs.SetString("timeKey", DateTime.Now.ToString());切换系统语言后DateTime.Parse(PlayerPrefs.GetString("timeKey"));报错FormatException: String was not recognized as a valid D…...

深度学习和神经网络

人工神经网络分为两个阶段&#xff1a; 1 &#xff1a;接收来自其他n个神经元传递过来的信号&#xff0c;这些输入信号通过与相应的权重进行 加权求和传递给下个阶段。&#xff08;预激活阶段&#xff09; 2&#xff1a;把预激活的加权结果传递给激活函数 sum :加权 f:激活…...

在CSDN学Golang云原生(Kubernetes Volume)

一&#xff0c;Volume 与 configMap Kubernetes 中的 Volume 和 ConfigMap 都是 Kubernetes 中常用的资源对象。它们可以为容器提供持久化存储和配置文件等。 Volume 可以将容器内部的文件系统挂载到宿主机上&#xff0c;也可以将多个容器间共享一个 Volume&#xff0c;并且 …...

第十五章 友元 异常和其他

RTTI RTTI是什么 RTTI是运行阶段类型识别&#xff0c;通过运行时类型识别&#xff0c;程序能够使用基类的指针或者引用来检查这些指针或者引用所指向的对象的实际派生类型。 RTTI的三个元素 dynamic_cast运算符 dynamic_cast概念&#xff1a; dynamic_cast运算符能够将基…...

制作DBC文件

​​​​​​​ ​​​​​​​ ​​​​​​​ ​​​​​​​ ​​​​​​​ ​​​​​​​ DBC文件是CAN通讯的密码本&#xff0c;Matlab的SimuLink中常用DBC作为CAN通讯的解析桥梁 制作DBC文件&#xff0c;内容是转速、位置&…...

【1.1】Java微服务:初识微服务

✅作者简介&#xff1a;大家好&#xff0c;我是 Meteors., 向往着更加简洁高效的代码写法与编程方式&#xff0c;持续分享Java技术内容。 &#x1f34e;个人主页&#xff1a;Meteors.的博客 &#x1f49e;当前专栏&#xff1a; 微服务 ✨特色专栏&#xff1a; 知识分享 &#x…...

数据结构--串、数组、广义表

这里写目录标题 串定义案例引用串的类型定义以及存储结构抽象类型定义存储结构(顺序表较为常用)顺序存储结构链式存储结构 串的模式匹配算法&#xff08;查找主串中是否有某个字串&#xff09;BF算法KMP算法设计思想对字串的回溯进行了优化代码对next【j】进行优化 数组类型一维…...

白银挑战——链表高频面试算法题

算法通关村第一关–链表白银挑战笔记 开始时间&#xff1a;2023年7月18日14:39:36 链表 Java中定义一个链表 class ListNode {public int val;public ListNode next;ListNode(int x) {val x;next null;}}1、四种方法解决两个链表第一个公共子节点 解释一下什么是公共节点 如…...

海外腾讯云账号:腾讯云高性能计算平台 THPC

高性能计算平台&#xff08;TencentCloud High Performance Computing&#xff0c;THPC&#xff09;是一款腾讯云自研的高性能计算资源管理服务&#xff0c;集成腾讯云上的计算、存储、网络等产品资源&#xff0c;并整合 HPC 专用作业管理调度、集群管理等软件&#xff0c;向用…...

eclipse 最新版没有navigator视图如何解决

使用project exploere视图可以显示类似navigator视图 1.显示project exploere视图 window---->show view --->project exploere 2.project exploere视图转换为类似navigator视图 第一步&#xff1a;点击视图右上角三个点或者倒三角&#xff0c;点击fiters and custom…...

Zynq-Linux移植学习笔记之62- PL挂载复旦微flash

1、背景介绍 现在为了全国产化需要&#xff0c;之前所有的进口flash全部要换成国产flash 2、复旦微flash型号 其中EFM25QU256和EFM25QL256对标winbond的w25q256 nor flash 3、FPGA设置 复旦微flash只支持单线模式&#xff0c;当使用PL侧的IP核访问时&#xff0c;需要设置模式…...

SpringBoot复习:(2)Tomcat容器是怎么启动的?

SpringApplication的run方法包含如下代码&#xff1a; 其中调用的refreshContext代码如下&#xff1a; 其中调用的refresh方法片段如下&#xff1a; 其中调用的refresh方法代码如下&#xff1a; 其中调用的super.refresh方法代码如下&#xff1a; public void refresh() th…...

1 MobileHomeTopicApplication

目录 1 OrderApplication 1.1 引用文件 1.2 #region 字段 1.3 #region 属性 OrderApplication 引用文件using System; using...

mpi4py包安装报错

报错情况 #include <mpi.h>^~~~~~~compilation terminated.failure.removing: _configtest.c _configtest.oerror: Cannot compile MPI programs. Check your configuration!!![end of output]note: This error originates from a subprocess, and is likely not a probl…...

浏览器访问 AWS ECS 上部署的 Docker 容器(监听 80 端口)

✅ 一、ECS 服务配置 Dockerfile 确保监听 80 端口 EXPOSE 80 CMD ["nginx", "-g", "daemon off;"]或 EXPOSE 80 CMD ["python3", "-m", "http.server", "80"]任务定义&#xff08;Task Definition&…...

应用升级/灾备测试时使用guarantee 闪回点迅速回退

1.场景 应用要升级,当升级失败时,数据库回退到升级前. 要测试系统,测试完成后,数据库要回退到测试前。 相对于RMAN恢复需要很长时间&#xff0c; 数据库闪回只需要几分钟。 2.技术实现 数据库设置 2个db_recovery参数 创建guarantee闪回点&#xff0c;不需要开启数据库闪回。…...

鸿蒙中用HarmonyOS SDK应用服务 HarmonyOS5开发一个医院挂号小程序

一、开发准备 ​​环境搭建​​&#xff1a; 安装DevEco Studio 3.0或更高版本配置HarmonyOS SDK申请开发者账号 ​​项目创建​​&#xff1a; File > New > Create Project > Application (选择"Empty Ability") 二、核心功能实现 1. 医院科室展示 /…...

根据万维钢·精英日课6的内容,使用AI(2025)可以参考以下方法:

根据万维钢精英日课6的内容&#xff0c;使用AI&#xff08;2025&#xff09;可以参考以下方法&#xff1a; 四个洞见 模型已经比人聪明&#xff1a;以ChatGPT o3为代表的AI非常强大&#xff0c;能运用高级理论解释道理、引用最新学术论文&#xff0c;生成对顶尖科学家都有用的…...

什么?连接服务器也能可视化显示界面?:基于X11 Forwarding + CentOS + MobaXterm实战指南

文章目录 什么是X11?环境准备实战步骤1️⃣ 服务器端配置(CentOS)2️⃣ 客户端配置(MobaXterm)3️⃣ 验证X11 Forwarding4️⃣ 运行自定义GUI程序(Python示例)5️⃣ 成功效果![在这里插入图片描述](https://i-blog.csdnimg.cn/direct/55aefaea8a9f477e86d065227851fe3d.pn…...

Java面试专项一-准备篇

一、企业简历筛选规则 一般企业的简历筛选流程&#xff1a;首先由HR先筛选一部分简历后&#xff0c;在将简历给到对应的项目负责人后再进行下一步的操作。 HR如何筛选简历 例如&#xff1a;Boss直聘&#xff08;招聘方平台&#xff09; 直接按照条件进行筛选 例如&#xff1a…...

在Ubuntu24上采用Wine打开SourceInsight

1. 安装wine sudo apt install wine 2. 安装32位库支持,SourceInsight是32位程序 sudo dpkg --add-architecture i386 sudo apt update sudo apt install wine32:i386 3. 验证安装 wine --version 4. 安装必要的字体和库(解决显示问题) sudo apt install fonts-wqy…...

Docker 本地安装 mysql 数据库

Docker: Accelerated Container Application Development 下载对应操作系统版本的 docker &#xff1b;并安装。 基础操作不再赘述。 打开 macOS 终端&#xff0c;开始 docker 安装mysql之旅 第一步 docker search mysql 》〉docker search mysql NAME DE…...

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

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

JS手写代码篇----使用Promise封装AJAX请求

15、使用Promise封装AJAX请求 promise就有reject和resolve了&#xff0c;就不必写成功和失败的回调函数了 const BASEURL ./手写ajax/test.jsonfunction promiseAjax() {return new Promise((resolve, reject) > {const xhr new XMLHttpRequest();xhr.open("get&quo…...