Golang container/list.List.MoveAfter() function example
package container/list
MoveAfter moves an element (1st parameter) to its new position after 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.MoveAfter() 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.MoveAfter(e, mark)
for e := alist.Front(); e != nil; e = e.Next() {
fmt.Println(e.Value) // print out the elements
}
}
Output :
a
b
c
d
Reference :
Advertisement
Something interesting
Tutorials
+14.8k Golang : Normalize unicode strings for comparison purpose
+5.7k Golang : ROT32768 (rotate by 0x80) UTF-8 strings example
+14.2k Golang : Fix image: unknown format error
+37.5k Golang : Converting a negative number to positive number
+5.9k Unix/Linux : How to open tar.gz file ?
+9.2k Golang : does not implement flag.Value (missing Set method)
+41.9k Golang : How do I convert int to uint8?
+10.9k Golang : Sieve of Eratosthenes algorithm
+7.7k Golang : Command line ticker to show work in progress
+10.6k Golang : Simple File Server
+36.4k Golang : Convert date or time stamp from string to time.Time type
+12.5k Golang : "https://" not allowed in import path