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
+5.2k Golang : Issue HTTP commands to server and port example
+16.4k Golang :Trim white spaces from a string
+29.9k Golang : Record voice(audio) from microphone to .WAV file
+11.1k How to test Facebook App on localhost ?
+19.4k Golang : Get RGBA values of each image pixel
+9.6k Golang : Changing a RGBA image number of channels with OpenCV
+10.6k RPM : error: db3 error(-30974) from dbenv->failchk: DB_RUNRECOVERY: Fatal error, run database recovery
+5.1k Linux : How to set root password in Linux Mint
+6.1k Fontello : How to load and use fonts?
+11.4k Golang : How to pipe input data to executing child process?
+18.9k Golang : Implement getters and setters
+21k Golang : Convert PNG transparent background image to JPG or JPEG image