Skip to content

链表

  • 双向链表: list.List
  • 环形链表: list.ring

什么是链表

需要学习数据结构与算法

基本使用

go
package main

import (
	"Container/list"
	"fmt"
)

func main() {
	linkedList := list.New()

	// 添加节点
	linkedList.PushBack("张三")
	linkedList.PushBack("李四")
	linkedList.PushBack("王五")

	// 遍历所有节点
	for node := linkedList.Front(); node != nil; node = node.Next() {
		fmt.Println(node.Value)
	}
}

Released under the MIT License.