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
+8k Golang : What fmt.Println() can do and println() cannot do
+7.3k Golang : File system scanning
+5.3k Python : Convert(cast) string to bytes example
+33k Golang : How to check if a date is within certain range?
+41.2k Golang : How to count duplicate items in slice/array?
+11.2k Golang : Proper way to test CIDR membership of an IP 4 or 6 address example
+6.7k Golang : Skip or discard items of non-interest when iterating example
+5.4k Golang : Intercept, inject and replay HTTP traffics from web server
+8k Golang : Sort words with first uppercase letter
+15.2k Golang : Get timezone offset from date or timestamp
+17.6k Convert JSON to CSV in Golang
+13.6k Android Studio : Password input and reveal password example