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.9k Setting $GOPATH environment variable for Unix/Linux and Windows
+5.3k PHP : Hide PHP version information from curl
+16.9k Golang : How to generate QR codes?
+8.2k Golang : Routes multiplexer routing example with regular expression control
+13.8k Generate salted password with OpenSSL example
+9k Golang : automatically figure out array length(size) with three dots
+47.8k Golang : Convert int to byte array([]byte)
+26.8k Golang : Convert file content into array of bytes
+20k Golang : Convert(cast) bytes.Buffer or bytes.NewBuffer type to io.Reader
+10.7k Golang : Interfacing with PayPal's IPN(Instant Payment Notification) example
+8.2k Golang : Add build version and other information in executables
+16.4k Golang : Test floating point numbers not-a-number and infinite example