Golang container/list.List.InsertAfter() function example
package container/list
InsertAfter inserts a new element with given value immediately after mark and returns the new element. If mark is not an element of the list, the list is not modified.
Golang container/list.List.InsertAfter() function usage example
package main
import (
"container/list"
"fmt"
)
func main() {
alist := list.New()
insertelem := alist.PushBack("a")
alist.PushBack("c")
alist.InsertAfter("b",insertelem)
for e := alist.Front(); e != nil; e = e.Next() {
fmt.Println(e.Value) // print out the elements
}
}
Output :
a
b
c
Reference :
Advertisement
Something interesting
Tutorials
+10k Golang : Read file and convert content to string
+6.2k PHP : How to handle URI or URL with non-ASCII characters such as Chinese/Japanese/Korean(CJK) ?
+6.8k Golang : Get expvar(export variables) to work with multiplexer
+21.6k Golang : GORM create record or insert new record into database example
+12.3k Golang : Display list of countries and ISO codes
+8.1k Golang : Tell color name with OpenCV example
+13.6k Golang : Set image canvas or background to transparent
+9.7k Random number generation with crypto/rand in Go
+5.8k Golang : Launching your executable inside a console under Linux
+32.5k Golang : Copy directory - including sub-directories and files
+5.9k Golang : Shuffle array of list