Golang container/list.List.MoveBefore() function example
package container/list
MoveAfter moves an element (1st parameter) to its new position before mark (2nd parameter) in the list. If the element or mark is not an element of the list, or e == mark, the list is not modified.
Golang container/list.List.MoveBefore() function usage example
package main
import (
"container/list"
"fmt"
)
func main() {
alist := list.New()
alist.PushBack("a")
alist.PushBack("b")
mark := alist.PushBack("c")
e := alist.PushBack("d")
alist.MoveBefore(e, mark)
for e := alist.Front(); e != nil; e = e.Next() {
fmt.Println(e.Value) // print out the elements
}
}
Output :
a
b
d
c
Reference :
Advertisement
Something interesting
Tutorials
+22.5k Golang : Convert Unix timestamp to UTC timestamp
+7.4k Golang : Example of custom handler for Gorilla's Path usage.
+10.2k Golang : How to get quoted string into another string?
+19.6k Golang : Get current URL example
+20.2k Golang : Reset or rewind io.Reader or io.Writer
+10k Golang : Convert octal value to string to deal with leading zero problem
+12.1k Golang : convert(cast) string to integer value
+13.7k Golang : Image to ASCII art example
+13.7k Golang : Activate web camera and broadcast out base64 encoded images
+7.3k Golang : Fixing Gorilla mux http.FileServer() 404 problem
+8.7k Golang : Find duplicate files with filepath.Walk
+25.7k Golang : How to write CSV data to file