wip: 保存 Go 练习和技术笔记

This commit is contained in:
2026-09-24 14:16:17 +08:00
parent 64cc3ec381
commit babd8f2793
20 changed files with 1229 additions and 29 deletions
+29
View File
@@ -0,0 +1,29 @@
package main
import (
"fmt"
"lab/algorithms/linkedlist"
)
func main() {
var list linkedlist.LinkedList[int] // 零值即为空表
list.InsertTail(3)
list.InsertTail(5)
list.InsertHead(1)
list.InsertHead(0)
fmt.Println(&list) // 0 -> 1 -> 3 -> 5 -> nil
list.DeleteHead()
list.DeleteTail()
fmt.Println(&list) // 1 -> 3 -> nil
found := list.Search(3)
if found != nil {
fmt.Printf("找到节点,Data = %d\n", found.Data)
}
list.Reverse()
fmt.Println(&list) // 3 -> 1 -> nil
fmt.Printf("链表长度: %d\n", list.Len())
}