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
+23.1k Golang : Randomly pick an item from a slice/array example
+8.8k Golang : On lambda, anonymous, inline functions and function literals
+5.2k Golang : Convert lines of string into list for delete and insert operation
+8.5k Golang : How to check if input string is a word?
+7.5k Golang : Process json data with Jason package
+14.4k Android Studio : Use image as AlertDialog title with custom layout example
+11.6k Swift : Convert (cast) Float to String
+18.8k Golang : Delete duplicate items from a slice/array
+6.1k nginx : force all pages to be SSL
+7.2k Golang : Null and nil value
+13.6k Golang : reCAPTCHA example
+12.6k Golang : Transform comma separated string to slice example