Initialize a ring of 5 and walk it
r := ring.New(5)
for i := 0; i < r.Len(); i++ {
r.Value = i
r = r.Next()
}
r.Do(func(x any) { fmt.Println(x) })
container/ringCircular linked list. Fixed-size ring buffer where advancing past the end loops to the front. Rarely needed.
r := ring.New(5)
for i := 0; i < r.Len(); i++ {
r.Value = i
r = r.Next()
}
r.Do(func(x any) { fmt.Println(x) })