Golang container/list.List.InsertBefore() function example
package container/list
InsertBefore inserts a new element with given value immediately before mark and returns the new element. If mark is not an element of the list, the list is not modified.
Golang container/list.List.InsertBefore() function usage example
package main
import (
"container/list"
"fmt"
)
func main() {
alist := list.New()
insertelem := alist.PushFront("a")
alist.PushFront("c")
alist.InsertBefore("b",insertelem)
for e := alist.Front(); e != nil; e = e.Next() {
fmt.Println(e.Value) // print out the elements
}
}
Output :
c
b
a
Reference :
Advertisement
Something interesting
Tutorials
+8k Golang : Handle Palindrome string with case sensitivity and unicode
+4.7k MariaDB/MySQL : Form select statement or search query with Chinese characters
+15.9k Golang : Update database with GORM example
+9k Golang : Go as a script or running go with shebang/hashbang style
+6.1k Golang : Scan forex opportunities by Bollinger bands
+11.3k Golang : Characters limiter example
+23.5k Golang : Read a file into an array or slice example
+9.6k Golang : Read file with ioutil
+5.9k Golang : Denco multiplexer example
+7.8k Golang : Load DSA public key from file example
+6.5k Elasticsearch : Shutdown a local node