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
+10.2k Golang : How to profile or log time spend on execution?
+8.7k Golang : Find duplicate files with filepath.Walk
+11.1k Golang : Read until certain character to break for loop
+6.9k Mac OSX : Find large files by size
+5.9k Golang : Use NLP to get sentences for each paragraph example
+10k Golang : Read file and convert content to string
+23.5k Golang : Read a file into an array or slice example
+6.1k Golang : Build new URL for named or registered route with Gorilla webtoolkit example
+6.8k Golang : Find the longest line of text example
+5.4k Python : Delay with time.sleep() function example
+48.1k Golang : How to convert JSON string to map and slice
+8.8k Golang : HTTP Routing with Goji example