ringparam

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 30, 2022 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Ring

type Ring[T any] struct {
	// contains filtered or unexported fields
}

func New

func New[T any](n int) *Ring[T]

func (*Ring[T]) Do

func (r *Ring[T]) Do(f func(v T, hasValue bool))

Do is equivalent of `container/ring`.Do but added hasValue boolean. hasValue is false if internal Value is nil, indicating passed value is zero of T. hasValue is true othrewize.

func (*Ring[T]) Get

func (r *Ring[T]) Get() (v T, ok bool)

Get returns internal Value. If internal Value is non-nil and then returns value and true. Otherwise returns zero of T and false.

func (*Ring[T]) Len

func (r *Ring[T]) Len() int
func (r *Ring[T]) Link(s *Ring[T]) *Ring[T]

func (*Ring[T]) Move

func (r *Ring[T]) Move(n int) *Ring[T]

func (*Ring[T]) Next

func (r *Ring[T]) Next() *Ring[T]

func (*Ring[T]) Prev

func (r *Ring[T]) Prev() *Ring[T]

func (*Ring[T]) Set

func (r *Ring[T]) Set(v T) *Ring[T]

Set sets value to inner `ring.Value` and returns that Ring.

func (r *Ring[T]) Unlink(n int) *Ring[T]

func (*Ring[T]) Unwrap

func (r *Ring[T]) Unwrap() *ring.Ring

Unwrap returns internal *`container/rinng`.Ring. Setting non-T value may cause runtime panic in succeeding Get or Do call.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL