arraystack

package
v3.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2025 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArrayStack

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

ArrayStack represents a LIFO (last-in, first-out) stack implemented using a slice.

func New

func New[T any](initialCapacity int) *ArrayStack[T]

New creates and returns a new, empty stack with the specified initial capacity.

func (*ArrayStack[T]) Clear

func (s *ArrayStack[T]) Clear()

Clear removes all items from the stack, leaving it empty.

func (*ArrayStack[T]) IsEmpty

func (s *ArrayStack[T]) IsEmpty() bool

IsEmpty checks if the stack is empty.

func (*ArrayStack[T]) Len

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

Len returns the number of items currently in the stack.

func (*ArrayStack[T]) Peek

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

Peek returns the item at the top of the stack without removing it. Returns false if the stack is empty.

func (*ArrayStack[T]) Pop

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

Pop removes and returns the item from the top of the stack. Returns false if the stack is empty.

func (*ArrayStack[T]) Push

func (s *ArrayStack[T]) Push(item T)

Push adds an item to the top of the stack.

Jump to

Keyboard shortcuts

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