stack

package
v0.0.28 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2026 License: MIT Imports: 0 Imported by: 0

Documentation

Overview

Package stack provides reusable stack helpers for validation/runtime state.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Stack

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

Stack is a reusable LIFO stack for validation state.

func NewStack

func NewStack[T any](capacity int) Stack[T]

NewStack creates a stack with an optional capacity hint.

func (*Stack[T]) Cap

func (s *Stack[T]) Cap() int

Cap reports the underlying slice capacity.

func (*Stack[T]) Drop

func (s *Stack[T]) Drop()

Drop clears the stack and releases backing storage.

func (*Stack[T]) Items

func (s *Stack[T]) Items() []T

Items returns the stack backing slice in push order.

func (*Stack[T]) Len

func (s *Stack[T]) Len() int

Len reports the current stack depth.

func (*Stack[T]) Peek

func (s *Stack[T]) Peek() (T, bool)

Peek returns the top value without removing it.

func (*Stack[T]) Pop

func (s *Stack[T]) Pop() (T, bool)

Pop removes and returns the top value.

func (*Stack[T]) Push

func (s *Stack[T]) Push(value T)

Push adds one value to the stack top.

func (*Stack[T]) Reset

func (s *Stack[T]) Reset()

Reset clears the stack while retaining capacity.

Jump to

Keyboard shortcuts

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