stack

package
v2.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2024 License: MIT Imports: 1 Imported by: 0

Documentation

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 last-in-first-out data structure

func New

func New[T any]() *Stack[T]

New creates a new stack

func (*Stack[T]) Clear

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

Clear empty the stack

func (*Stack[T]) IsEmpty

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

IsEmpty checks if stack is empty

func (*Stack[T]) Len

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

Len returns the length of the stack.

func (*Stack[T]) Peek

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

Peek helps view the top item on the stack

func (*Stack[T]) Pop

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

Pop removes and return top element of stack. Return false if stack is empty.

func (*Stack[T]) Push

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

Push a new value onto the stack

Jump to

Keyboard shortcuts

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