Golang container/ring.Ring.Next function example
package container/ring
Next returns the next ring element. The ring that is going to be "next"ed must not be empty.
Golang container/ring.Ring.Next function usage
package main
import (
"container/ring"
"fmt"
)
func main() {
r := ring.New(10)
// populate our ring
for i := 0; i < 10; i++ {
r.Value = i
r = r.Next() // Next element to populate
}
f := func(v interface{}) {
fmt.Printf("%d ", v)
}
fmt.Println("Values in ring ")
r.Do(f)
fmt.Println()
}
Output :
Values in ring
0 1 2 3 4 5 6 7 8 9
Reference :
Advertisement
Something interesting
Tutorials
+7.9k Setting $GOPATH environment variable for Unix/Linux and Windows
+7.7k Golang : Command line ticker to show work in progress
+10.9k Golang : How to transmit update file to client by HTTP request example
+14.2k Golang : Chunk split or divide a string into smaller chunk example
+12.4k Golang : Encrypt and decrypt data with x509 crypto
+26.1k Mac/Linux and Golang : Fix bind: address already in use error
+7.8k Golang : Scan files for certain pattern and rename part of the files
+11.2k Golang : Calculate Relative Strength Index(RSI) example
+6.9k Golang : Fibonacci number generator examples
+13.6k Golang : Strings comparison
+12.8k Swift : Convert (cast) Int or int32 value to CGFloat