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

@@ -10,7 +10,7 @@ use std::rc::Rc;
use std::cell::RefCell;
use list_node::ListNode;
/* 在链表的点 n0 之后插入点 P */
/* 在链表的点 n0 之后插入点 P */
#[allow(non_snake_case)]
pub fn insert<T>(n0: &Rc<RefCell<ListNode<T>>>, P: Rc<RefCell<ListNode<T>>>) {
let n1 = n0.borrow_mut().next.take();
@@ -18,7 +18,7 @@ pub fn insert<T>(n0: &Rc<RefCell<ListNode<T>>>, P: Rc<RefCell<ListNode<T>>>) {
n0.borrow_mut().next = Some(P);
}
/* 删除链表的点 n0 之后的首个*/
/* 删除链表的点 n0 之后的首个*/
#[allow(non_snake_case)]
pub fn remove<T>(n0: &Rc<RefCell<ListNode<T>>>) {
if n0.borrow().next.is_none() {return};
@@ -30,7 +30,7 @@ pub fn remove<T>(n0: &Rc<RefCell<ListNode<T>>>) {
}
}
/* 访问链表中索引为 index 的*/
/* 访问链表中索引为 index 的*/
pub fn access<T>(head: Rc<RefCell<ListNode<T>>>, index: i32) -> Rc<RefCell<ListNode<T>>> {
if index <= 0 {return head};
if let Some(node) = &head.borrow_mut().next {
@@ -39,7 +39,7 @@ pub fn access<T>(head: Rc<RefCell<ListNode<T>>>, index: i32) -> Rc<RefCell<ListN
return head;
}
/* 在链表中查找值为 target 的首个*/
/* 在链表中查找值为 target 的首个*/
pub fn find<T: PartialEq>(head: Rc<RefCell<ListNode<T>>>, target: T, index: i32) -> i32 {
if head.borrow().val == target {return index};
if let Some(node) = &head.borrow_mut().next {
@@ -51,7 +51,7 @@ pub fn find<T: PartialEq>(head: Rc<RefCell<ListNode<T>>>, target: T, index: i32)
/* Driver Code */
fn main() {
/* 初始化链表 */
// 初始化各个
// 初始化各个
let n0 = ListNode::new(1);
let n1 = ListNode::new(3);
let n2 = ListNode::new(2);
@@ -65,21 +65,21 @@ fn main() {
print!("初始化的链表为 ");
print_util::print_linked_list(&n0);
/* 插入*/
/* 插入*/
insert(&n0, ListNode::new(0));
print!("插入点后的链表为 ");
print!("插入点后的链表为 ");
print_util::print_linked_list(&n0);
/* 删除*/
/* 删除*/
remove(&n0);
print!("删除点后的链表为 ");
print!("删除点后的链表为 ");
print_util::print_linked_list(&n0);
/* 访问*/
/* 访问*/
let node = access(n0.clone(), 3);
println!("链表中索引 3 处的点的值 = {}", node.borrow().val);
println!("链表中索引 3 处的点的值 = {}", node.borrow().val);
/* 查找*/
/* 查找*/
let index = find(n0.clone(), 2, 0);
println!("链表中值为 2 的点的索引 = {}", index);
println!("链表中值为 2 的点的索引 = {}", index);
}