Golang container/list.List.MoveToFront() function example
package container/list
MoveToFront moves element e (1st parameter) to the front of the given list. If e is not an element of the list, the list is not modified.
Golang container/list.List.MoveToFront() function usage example
package main
import (
"container/list"
"fmt"
)
func main() {
alist := list.New()
alist.PushBack("a")
alist.PushBack("b")
e := alist.PushBack("c")
alist.PushBack("d")
alist.MoveToFront(e)
for e := alist.Front(); e != nil; e = e.Next() {
fmt.Println(e.Value) // print out the elements
}
}
Output :
c <---- moved to the front of the list
a
b
d
Reference :
Advertisement
Something interesting
Tutorials
+10.6k Golang : Get local time and equivalent time in different time zone
+40.5k Golang : Convert to io.ReadSeeker type
+10.1k Golang : Check a web page existence with HEAD request example
+29.4k Golang : JQuery AJAX post data to server and send data back to client example
+6.6k Golang : Warp text string by number of characters or runes example
+32.7k Golang : Regular Expression for alphanumeric and underscore
+14.6k Golang : Send email with attachment(RFC2822) using Gmail API example
+21.7k Golang : Setting up/configure AWS credentials with official aws-sdk-go
+19.9k Golang : How to get time from unix nano example
+11.9k Golang : Convert decimal number(integer) to IPv4 address
+7.3k Golang : How to iterate a slice without using for loop?