美文网首页
Learn Golang List

Learn Golang List

作者: 笑吧小鸟 | 来源:发表于2019-02-12 23:05 被阅读2次

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

      本文链接:https://www.haomeiwen.com/subject/sivleqtx.html