Update 链表理论基础.md

This commit is contained in:
fw_qaq
2022-09-28 16:40:21 +08:00
committed by GitHub
parent 626f985e0a
commit 5252cfc060

View File

@ -220,16 +220,17 @@ class ListNode(_x: Int = 0, _next: ListNode = null) {
Rust: Rust:
```rust ```rust
pub struct Node<T> { #[derive(PartialEq, Eq, Clone, Debug)]
value: T, pub struct ListNode<T> {
next: Link<T>, pub val: T,
pub next: Option<Box<ListNode<T>>>,
} }
type Link<T> = Option<Box<Node<T>>>; impl<T> ListNode<T> {
#[inline]
// 附设头节点 fn new(val: T, node: Option<Box<ListNode<T>>>) -> Self {
pub struct List<T> { ListNode { next: node, val }
head: Link<T>, }
} }
``` ```