Golang container/list.List.PushFrontList() function example
package container/list
PushFrontList inserts a copy of an other list at the front of the given list . The lists and other may be the same.
Golang container/list.List.PushFrontList() function usage example
package main
import (
"container/list"
"fmt"
)
func main() {
alist := list.New()
alist.PushBack("a")
alist.PushBack("b")
alist.PushBack("c")
blist := list.New()
blist.PushBack("d")
blist.PushBack("e")
blist.PushBack("f")
alist.PushFrontList(blist)
for e := alist.Front(); e != nil; e = e.Next() {
fmt.Println(e.Value) // print out the elements
}
}
Output :
d
e
f
a
b
c
Reference :
Advertisement
Something interesting
Tutorials
+5.8k Golang : Launching your executable inside a console under Linux
+23.1k Golang : simulate tail -f or read last line from log file example
+10.1k Golang : Get login name from environment and prompt for password
+10k Golang : Get escape characters \u form from unicode characters
+9.9k Golang : Check if user agent is a robot or crawler example
+29.3k Golang : Save map/struct to JSON or XML file
+9.7k Golang : Populate slice with sequential integers example
+22.1k Golang : Repeat a character by multiple of x factor
+13k Golang : Get terminal width and height example
+44.9k Golang : Use wildcard patterns with filepath.Glob() example
+23.9k Golang : Use regular expression to validate domain name