refactor: Replace 结点 with 节点 (#452)

* Replace 结点 with 节点
Update the footnotes in the figures

* Update mindmap

* Reduce the size of the mindmap.png
This commit is contained in:
Yudong Jin
2023-04-09 04:32:17 +08:00
committed by GitHub
parent 3f4e32b2b0
commit 1c8b7ef559
395 changed files with 2056 additions and 2056 deletions

View File

@@ -9,11 +9,11 @@ include!("../include/include.rs");
use std::rc::Rc;
use std::cell::RefCell;
/* 双向链表*/
/* 双向链表*/
pub struct ListNode<T> {
pub val: T, // 点值
pub next: Option<Rc<RefCell<ListNode<T>>>>, // 后继点引用(指针)
pub prev: Option<Rc<RefCell<ListNode<T>>>>, // 前驱点引用(指针)
pub val: T, // 点值
pub next: Option<Rc<RefCell<ListNode<T>>>>, // 后继点引用(指针)
pub prev: Option<Rc<RefCell<ListNode<T>>>>, // 前驱点引用(指针)
}
impl<T> ListNode<T> {
@@ -29,8 +29,8 @@ impl<T> ListNode<T> {
/* 基于双向链表实现的双向队列 */
#[allow(dead_code)]
pub struct LinkedListDeque<T> {
front: Option<Rc<RefCell<ListNode<T>>>>, // 头点 front
rear: Option<Rc<RefCell<ListNode<T>>>>, // 尾点 rear
front: Option<Rc<RefCell<ListNode<T>>>>, // 头点 front
rear: Option<Rc<RefCell<ListNode<T>>>>, // 尾点 rear
que_size: usize, // 双向队列的长度
}
@@ -63,7 +63,7 @@ impl<T: Copy> LinkedListDeque<T> {
Some(old_front) => {
old_front.borrow_mut().prev = Some(node.clone());
node.borrow_mut().next = Some(old_front);
self.front = Some(node); // 更新头
self.front = Some(node); // 更新头
}
None => {
self.rear = Some(node.clone());
@@ -77,7 +77,7 @@ impl<T: Copy> LinkedListDeque<T> {
Some(old_rear) => {
old_rear.borrow_mut().next = Some(node.clone());
node.borrow_mut().prev = Some(old_rear);
self.rear = Some(node); // 更新尾
self.rear = Some(node); // 更新尾
}
None => {
self.front = Some(node.clone());
@@ -107,7 +107,7 @@ impl<T: Copy> LinkedListDeque<T> {
match old_front.borrow_mut().next.take() {
Some(new_front) => {
new_front.borrow_mut().prev.take();
self.front = Some(new_front); // 更新头
self.front = Some(new_front); // 更新头
}
None => {
self.rear.take();
@@ -122,7 +122,7 @@ impl<T: Copy> LinkedListDeque<T> {
match old_rear.borrow_mut().prev.take() {
Some(new_rear) => {
new_rear.borrow_mut().next.take();
self.rear = Some(new_rear); // 更新尾
self.rear = Some(new_rear); // 更新尾
}
None => {
self.front.take();

View File

@@ -13,8 +13,8 @@ use list_node::ListNode;
/* 基于链表实现的队列 */
#[allow(dead_code)]
pub struct LinkedListQueue<T> {
front: Option<Rc<RefCell<ListNode<T>>>>, // 头点 front
rear: Option<Rc<RefCell<ListNode<T>>>>, // 尾点 rear
front: Option<Rc<RefCell<ListNode<T>>>>, // 头点 front
rear: Option<Rc<RefCell<ListNode<T>>>>, // 尾点 rear
que_size: usize, // 队列的长度
}
@@ -39,15 +39,15 @@ impl<T: Copy> LinkedListQueue<T> {
/* 入队 */
pub fn push(&mut self, num: T) {
// 尾点后添加 num
// 尾点后添加 num
let new_rear = ListNode::new(num);
match self.rear.take() {
// 如果队列不为空,则将该点添加到尾点后
// 如果队列不为空,则将该点添加到尾点后
Some(old_rear) => {
old_rear.borrow_mut().next = Some(new_rear.clone());
self.rear = Some(new_rear);
}
// 如果队列为空,则令头、尾点都指向该
// 如果队列为空,则令头、尾点都指向该
None => {
self.front = Some(new_rear.clone());
self.rear = Some(new_rear);

View File

@@ -13,7 +13,7 @@ use list_node::ListNode;
/* 基于链表实现的栈 */
#[allow(dead_code)]
pub struct LinkedListStack<T> {
stack_peek: Option<Rc<RefCell<ListNode<T>>>>, // 将头点作为栈顶
stack_peek: Option<Rc<RefCell<ListNode<T>>>>, // 将头点作为栈顶
stk_size: usize, // 栈的长度
}