Learn Golang List

Learn Golang List

简介


  • list标准包contain中的双向链表

常见操作


  • 初始化
  • 插入
  • 删除

例子


package main

import "fmt"
import "container/list"

func main() {
    fmt.Println("init list")
    l := list.New()

    //插入
    l.PushBack("tail")

    fmt.Println(l)
    //头部添加
    l.PushFront("head")

    fmt.Println(l)

    // 遍历
    for i := l.Front(); i != nil; i = i.Next() {
        fmt.Println(i.Value)
    }
}

如何查看帮助


  • 终端运行godoc -http=:8080
  • 浏览器访问http://localost:8080/

你可能感兴趣的:(Learn Golang List)