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
pub struct Node<T> {
value: T,
next: Link<T>,
#[derive(PartialEq, Eq, Clone, Debug)]
pub struct ListNode<T> {
pub val: T,
pub next: Option<Box<ListNode<T>>>,
}
type Link<T> = Option<Box<Node<T>>>;
// 附设头节点
pub struct List<T> {
head: Link<T>,
impl<T> ListNode<T> {
#[inline]
fn new(val: T, node: Option<Box<ListNode<T>>>) -> Self {
ListNode { next: node, val }
}
}
```