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 : Convert(cast) string to int64
+7.9k Golang : Populate slice with sequential integers example
+39.5k Golang : Convert string to array/slice
+5k Grep : How to grep for strings inside binary data
+4.7k Golang : Detect face in uploaded photo like GPlus
+43.2k Golang : Encode image to base64 example
+10.1k Golang : Convert a rune to unicode style string \u
+14.5k Golang :Trim white spaces from a string
+4.6k Fontello : How to load and use fonts?
+6.8k Python : Fix SyntaxError: Non-ASCII character in file, but no encoding declared
+13.9k Golang : Convert date format and separator yyyy-mm-dd to dd-mm-yyyy
+20k Golang : Repeat a character by multiple of x factor