package main import ( "container/list" "fmt" ) func main() { // 生成队列 l := list.New() // 入队,压栈 l.PushBack(1) l.PushBack(2) l.PushBack(3) l.PushBack(4) // 出队 i1 := l.Front() l.Remove(i1) fmt.Printf("出队:%d\n",i1.Value) fmt.Printf("Len:%d\n",l.Len()) // 出栈 i4 := l.Back() l.Remove(i4) fmt.Printf("出栈:%d\n",i4.Value) fmt.Printf("Len:%d\n",l.Len()) }原文链接:https://www.f2er.com/go/191352.html