mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-08 00:43:04 +08:00
Update 链表理论基础.md
This commit is contained in:
@ -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 }
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
Reference in New Issue
Block a user