Home | History | Annotate | Download | only in ring

Lines Matching defs:ring

5 // Package ring implements operations on circular lists.
6 package ring
8 // A Ring is an element of a circular list, or ring.
9 // Rings do not have a beginning or end; a pointer to any ring element
10 // serves as reference to the entire ring. Empty rings are represented
11 // as nil Ring pointers. The zero value for a Ring is a one-element
12 // ring with a nil Value.
14 type Ring struct {
15 next, prev *Ring
19 func (r *Ring) init() *Ring {
25 // Next returns the next ring element. r must not be empty.
26 func (r *Ring) Next() *Ring {
33 // Prev returns the previous ring element. r must not be empty.
34 func (r *Ring) Prev() *Ring {
42 // in the ring and returns that ring element. r must not be empty.
44 func (r *Ring) Move(n int) *Ring {
61 // New creates a ring of n elements.
62 func New(n int) *Ring {
66 r := new(Ring)
69 p.next = &Ring{prev: p}
77 // Link connects ring r with ring s such that r.Next()
81 // If r and s point to the same ring, linking
82 // them removes the elements between r and s from the ring.
89 // them creates a single ring with the elements of s inserted
93 func (r *Ring) Link(s *Ring) *Ring {
107 // Unlink removes n % r.Len() elements from the ring r, starting
111 func (r *Ring) Unlink(n int) *Ring {
118 // Len computes the number of elements in ring r.
121 func (r *Ring) Len() int {
132 // Do calls function f on each element of the ring, in forward order.
134 func (r *Ring) Do(f func(interface{})) {