stack

package
v0.0.0-...-89d9e6b Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2025 License: GPL-3.0, LGPL-3.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsEmpty

func IsEmpty[T any](stack []T) bool

IsEmpty returns true iff stack is empty.

func IsFull

func IsFull[T any](stack []T) bool

IsFull returns true iff stack is full, i.e. at capacity.

func Peek

func Peek[T any](stack []T) (T, error)

Peek copies the top element of the stack.

Returns the element on the top of the stack or ErrEmpty if stack is empty. FIXME needs testing

func PeekN

func PeekN[T any](stack []T, n uint) ([]T, error)

PeekN peeks for the top `n` elements on the stack.

Returns slice of top `n` elements, or ErrEmpty if more elements are requested than are present. FIXME needs testing

func Pop

func Pop[T any](stack []T) ([]T, T, error)

Pop pops an element off the stack.

Returns updated stack and element, or ErrEmpty if stack is empty. FIXME needs testing

func PopN

func PopN[T any](stack []T, n uint) ([]T, []T, error)

PopN pops `n` elements off the stack.

Returns updated stack and elements, or ErrEmpty if more elements are popped than are present. FIXME needs testing

func Push

func Push[T any](stack []T, val T) ([]T, error)

Push pushes an element onto the stack.

Returns the updated stack, or ErrFull if stack is at full capacity.

func PushMany

func PushMany[T any](stack []T, vals []T) ([]T, error)

PushMany pushes a sequence of elements onto the stack.

Returns updated stack, or ErrFull if sequence is larger than capacity. FIXME needs testing (PushMany must end up in reverse order)

Types

This section is empty.

Jump to

Keyboard shortcuts

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