Source File
ring.go
Belonging Package
go.opentelemetry.io/otel/sdk/log
// Copyright The OpenTelemetry Authors// SPDX-License-Identifier: Apache-2.0// Copyright 2009 The Go Authors. All rights reserved.// Use of this source code is governed by a BSD-style// license that can be found in the LICENSE file.package log // import "go.opentelemetry.io/otel/sdk/log"// A ring is an element of a circular list, or ring. Rings do not have a// beginning or end; a pointer to any ring element serves as reference to the// entire ring. Empty rings are represented as nil ring pointers. The zero// value for a ring is a one-element ring with a nil Value.//// This is copied from the "container/ring" package. It uses a Record type for// Value instead of any to avoid allocations.type ring struct {next, prev *ringValue Record}func ( *ring) () *ring {.next =.prev =return}// Next returns the next ring element. r must not be empty.func ( *ring) () *ring {if .next == nil {return .init()}return .next}// Prev returns the previous ring element. r must not be empty.func ( *ring) () *ring {if .next == nil {return .init()}return .prev}// newRing creates a ring of n elements.func newRing( int) *ring {if <= 0 {return nil}:= new(ring):=for := 1; < ; ++ {.next = &ring{prev: }= .next}.next =.prev =return}// Len computes the number of elements in ring r. It executes in time// proportional to the number of elements.func ( *ring) () int {:= 0if != nil {= 1for := .Next(); != ; = .next {++}}return}// Do calls function f on each element of the ring, in forward order. The// behavior of Do is undefined if f changes *r.func ( *ring) ( func(Record)) {if != nil {(.Value)for := .Next(); != ; = .next {(.Value)}}}
![]() |
The pages are generated with Golds v0.8.2. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |