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
+7.3k Golang : Fixing Gorilla mux http.FileServer() 404 problem
+7k Golang : Levenshtein distance example
+21.7k Golang : Setting up/configure AWS credentials with official aws-sdk-go
+8.8k Golang : Heap sort example
+7.1k Golang : Get environment variable
+12.5k Golang : Forwarding a local port to a remote server example
+12.1k Golang : Detect user location with HTML5 geo-location
+19.6k Golang : Set or Add HTTP Request Headers
+27.5k Golang : dial tcp: too many colons in address
+11.3k Golang : Characters limiter example
+13.7k Golang : Tutorial on loading GOB and PEM files
+11.2k Golang : Fix - does not implement sort.Interface (missing Len method)