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