stack

package
v0.76.0 Latest Latest
Warning

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

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

Documentation

Overview

Package stack provides a simple Stack container.

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 represents a simple generic Stack. The zero value is an empty stack ready to use. A Stack is not thread safe.

func (*Stack[T]) Clear

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

Clear removes all items.

func (*Stack[T]) Peek

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

Peek tries to return the top element and reports whether it exists.

func (*Stack[T]) Pop

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

Pop tries to return the top element and reports whether it exists.

func (*Stack[T]) Push

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

Push adds an item on top.

func (*Stack[T]) Size

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

Size returns the number of items.

func (*Stack[T]) String

func (s *Stack[T]) String() string

String returns a string representation.

Jump to

Keyboard shortcuts

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