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.8k Golang : Natural string sorting example
+21.3k Golang : Create and resolve(read) symbolic links
+15.6k Golang : Convert date format and separator yyyy-mm-dd to dd-mm-yyyy
+18.5k Golang : Write file with io.WriteString
+11k How to test Facebook App on localhost ?
+19.2k Golang : Execute shell command
+5k Golang : Constant and variable names in native language
+27.9k Golang : Decode/unmarshal unknown JSON data type with map[string]interface
+22.1k Golang : Match strings by wildcard patterns with filepath.Match() function
+20.6k Golang : Secure(TLS) connection between server and client
+8.8k Android Studio : Image button and button example
+10k Golang : Channels and buffered channels examples