MCPcopy Create free account
hub / github.com/Monibuca/engine / Link

Method Link

util/ring.go:88–100  ·  view source on GitHub ↗

Link connects ring r with ring s such that r.Next() becomes s and returns the original value for r.Next(). r must not be empty. If r and s point to the same ring, linking them removes the elements between r and s from the ring. The removed elements form a subring and the result is a reference to th

(s *Ring[T])

Source from the content-addressed store, hash-verified

86// last element of s after insertion.
87//
88func (r *Ring[T]) Link(s *Ring[T]) *Ring[T] {
89 n := r.Next()
90 if s != nil {
91 p := s.Prev()
92 // Note: Cannot use multiple assignment because
93 // evaluation order of LHS is not specified.
94 r.next = s
95 s.prev = r
96 n.prev = p
97 p.next = n
98 }
99 return n
100}
101
102// Unlink removes n % r.Len() elements from the ring r, starting
103// at r.Next(). If n % r.Len() == 0, r remains unchanged.

Callers 3

UnlinkMethod · 0.95
GlowMethod · 0.80
recycleMethod · 0.80

Calls 2

NextMethod · 0.95
PrevMethod · 0.95

Tested by

no test coverage detected