tagstack

package
v0.1.10 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2024 License: ISC Imports: 2 Imported by: 0

Documentation

Overview

tagstack is a package that manages concurrent safe tag stacks. A caller uses the provided Push and Pop functions to push uint32 values onto/from the stack. It is the callers responsibility ensure uniqueness of the tags if this is desired.

tagstack deliberately uses uint32 instead of interface{} for performance reasons.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrOverflow  = errors.New("overflow")
	ErrUnderflow = errors.New("underflow")
)

Functions

This section is empty.

Types

type TagStack

type TagStack struct {
	sync.Mutex
	// contains filtered or unexported fields
}

TagStack is an opaque type that contains the tag stack.

func New

func New(depth int) *TagStack

New returns a pointer to a TagStack structure.

func NewBlocking

func NewBlocking(depth int) *TagStack

NewBlocking returns a pointer to a TagStack structure.

func (*TagStack) Depth

func (s *TagStack) Depth() int

Depth returns the tag stack depth.

func (*TagStack) Pop

func (s *TagStack) Pop() (uint32, error)

Pop returns the current tag on the stack. If the stack will underflow it will return an error.

func (*TagStack) Push

func (s *TagStack) Push(x uint32) error

Push appends x to then end of the stack. If the stack will overflow it will return an error.

Jump to

Keyboard shortcuts

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