久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長(zhǎng)資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      go語言 list用法是什么

      go語言中l(wèi)ist的用法:1、通過“l(fā) := list.New()”方式聲明鏈表;2、使用“l(fā)ist.Remove(element)”方式刪除元素;3、使用“l(fā)ist1.PushBackList(list2)”方式合并兩個(gè)鏈表即可。

      go語言 list用法是什么

      本文環(huán)境:windows10系統(tǒng)、Go1.11.2版,本文適用于所有品牌的電腦。

      推薦:《golang教程

      golang list用法筆記

      依賴

      import (         "container/list"         "fmt" )

      遍歷

      go的list也是用雙向循環(huán)鏈表實(shí)現(xiàn)的,在尾部追加用PushBack()

      // 聲明鏈表 l := list.New() // 數(shù)據(jù)添加到尾部 l.PushBack(4) l.PushBack(5) l.PushBack(6) // 遍歷 for e := l.Front(); e != nil; e = e.Next() {      fmt.Printf("%vn", e.Value) }

      刪除元素

      刪除使用list.Remove(element)

       l := list.New()  l.PushBack(4)  six := l.PushBack(6)  l.Remove(six) // 刪除6這個(gè)節(jié)點(diǎn)

      合并兩個(gè)鏈表(list1)
      這里面使用list1.PushBackList(list2)

      l := list.New() l.PushBack(1) l.PushBack(2) l.PushBack(3) l2 := list.New() l2.PushBack(4) l2.PushBack(5) l2.PushBack(6) l2.PushBackList(l2) fmt.Printf("merge after l================n") for e := l.Front(); e != nil; e = e.Next() {         fmt.Printf("%dn", e.Value.(int)) } fmt.Printf("merge after l2================n") for e := l2.Front(); e != nil; e = e.Next() {         fmt.Printf("%dn", e.Value.(int)) }

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號(hào)-2    滬公網(wǎng)安備31011702889846號(hào)